-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
49 lines (41 loc) · 1.36 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import "dotenv/config";
import express from "express";
// import session from "express-session";
// import ConnectMongoDBSession from "connect-mongodb-session";
import bodyParser from "body-parser";
import cors from "cors";
import logger from "morgan";
import routers from "./src/routes/index.js";
import { connectDB } from "./src/config/db.js";
import { error404Handler } from "./src/middleware/error_handler.js";
// const MongoDBStore = ConnectMongoDBSession(session)
const app = express();
// const store = new MongoDBStore({
// uri: process.env.MONGO_URL,
// databaseName: "testManagement",
// collection: "mySessions",
// });
// app.use(
// session({
// store: store,
// secret: process.env.JWT_SECRET,
// resave: false,
// saveUninitialized: true,
// cookie: {
// maxAge: 24 * 60 * 60 * 1000,
// },
// })
// );
app.use(cors({ origin: ['https://enfavedu.netlify.app', 'http://localhost:5173', 'https://enfavdu1.vercel.app'], credentials: true}));
process.env.NODE_ENV === "development" ? app.use(logger("dev")) : null;
connectDB(process.env.MONGO_URL);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
routers(app);
app.use(error404Handler);
const port = process.env.PORT || 4400;
app.listen(port, () => {
console.log(
`server started on [${process.env.NODE_ENV}] mode at port [${port}]`
);
});