-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
42 lines (30 loc) · 1.01 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
require('dotenv').config();
const express=require ('express');
const app=express();
const mongoose =require('mongoose');
const session = require('express-session');
const MongoStore = require('connect-mongo')(session);
const userRoute =require('./routes/user');
const adminRoute =require('./routes/admin');
const passport = require('passport');
const error = require('./middleware/error');
require('./config/passport')(passport)
const port = process.env.PORT || 4000;
mongoose.connect(process.env.MONGO_URI)
.then(() => console.log('connection is sussesful'))
.catch((err)=> console.log(err));
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: false,
cookie: { secure: true },
store: new MongoStore({ mongooseConnection: mongoose.connection })
}));
app.use(passport.initialize());
app.use(passport.session());
//app.use(express.json());
app.use('/',userRoute);
app.use('/admin',adminRoute);
app.use(error);
app.listen(port,()=>{console.log(`listning on port ${port}...`);
});