-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (30 loc) · 1015 Bytes
/
index.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
const express = require('express')
const app = express();
const dotenv = require('dotenv').config();
const nocache = require('nocache');
const path = require('path');
const session = require('express-session');
//connect Mongodb
const connectDB = require("./config/mongoose");
connectDB();// Call mongoose connection
//code configure middleware
app.use(express.json());
app.use(express.urlencoded({extended:true}));
// Serve static files from the 'public'
app.use(express.static(path.join(__dirname,'public')))
//session
const{v4:uuidv4}= require('uuid')
app.use(nocache()) //nocache
app.use(session({
secret: uuidv4(),
resave: false,
saveUninitialized: false,
}));
//for Admin route
const adminRoute = require('./routes/adminRoute');
app.use('/admin',adminRoute);
// for user route
const userRoute = require('./routes/userRoute');
app.use('/',userRoute);
const PORT = process.env.PORT || 5001;
app.listen(PORT,()=>{console.log(`Server is running http://localhost:${PORT}`)})