-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (31 loc) · 875 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
const mongoose =require('mongoose');
mongoose.connect("mongodb://localhost:27017/user_management")
const express= require('express');
//set port
const PORT = 3000;
const app = express();
//cache controle
app.use((req, res, next) => {
res.set(
"Cache-Control",
"no-store, no-cache, must-revalidate, proxy-revalidate"
);
res.set("Pragma", "no-cache");
res.set("Expires", "0");
res.set("Surrogate-Control", "no-store");
next();
});
//for user route
const userRoute = require('./routes/userRoute')
app.use('/',userRoute);
// for Admin route
const adminRoute = require('./routes/adminRoute')
app.use('/admin',adminRoute);
//error handling function
app.use((err, req, res, next) => {
console.error(err.stack);
res.status(500).send('Something broke!');
});
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});