-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (31 loc) · 932 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
const dotenv = require("dotenv");
dotenv.config();
// ----------------------------
// Database connection
const mongoose = require("mongoose");
mongoose.connect(process.env.DB_CONNECTION,console.log("db connected")).then("mongo sussess").catch("somrthing wrong");
// ----------------------------
//expess
const express = require("express");
const app = express();
const nocache = require("nocache");
const session = require("express-session")
// Session stuffs
app.use(session({
secret:process.env.SESSION_SECRET,
resave: true,
saveUninitialized: true
}));
app.use(nocache());
// bodyParser
app.use(express.urlencoded({extended:true}))
app.use(express.json());
// User_Routes
const userRoute = require("./routes/userRoute");
app.use('/',userRoute);
// Admin_Routes
const adminRoute = require("./routes/adminRoute");
app.use('/admin',adminRoute);
app.listen(3000,()=>{
console.log('Server running...')
});