const express = require("express"); const bodyParser = require("body-parser"); const cookieParser = require("cookie-parser"); const session = require("express-session"); const app = express(); require("dotenv").config(); require("./mailer"); const errorHandler = require("./_helpers/error-handler"); const { keycloak } = require("./kc"); app.use( process.env.NODE_ENV !== "production" ? (_, __, next) => next() : keycloak.middleware() ); app.use(cookieParser()); app.use( session({ secret: "so secret", resave: true, saveUninitialized: true }) ); app.use('/api', require('./routes')); app.use(bodyParser.json({ limit: "50mb" })); app.use(bodyParser.urlencoded({ limit: "50mb", extended: true })); app.use(errorHandler); app.listen(process.env.MANAGER_PORT, () => console.log(`Listening on http://localhost:${process.env.MANAGER_PORT}`) ); module.exports = app;