-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
35 lines (28 loc) · 801 Bytes
/
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
const { express, nocache, session, cookieParser } = require('./util/modules');
const app = express();
require("dotenv").config();
const { PORT, SECRET } = process.env
const connectMongoDB = require('./config/mongodb');
const userRoute = require("./routers/userRouter");
const adminRouter = require("./routers/adminRouter");
connectMongoDB()
app.use(nocache());
app.use(cookieParser());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.set("view engine", "ejs");
app.use(
session({
secret: SECRET,
resave: false,
saveUninitialized: true,
})
);
app.use("/admin", adminRouter);
app.use("/", userRoute);
app.use((error,req,res,next)=>{
console.error(error);
})
app.listen(PORT, () => {
console.log(`App is running on http://127.0.0.1:${PORT}`);
});