-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
38 lines (31 loc) · 955 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
36
37
38
const express = require('express');
const app = express();
const Routes = require('./Routes/router');
const session = require('express-session');
const passport = require('passport');
const mongoose = require('mongoose');
const dotenv = require('dotenv');
const Auth = require('./Routes/auth');
dotenv.config();
const PORT = process.env.PORT || 5000;
app.set('view engine', 'ejs');
app.use(express.json());
app.use(express.urlencoded( {extended: false}));
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: false
}));
require('./passport')(passport);
mongoose.connect('mongodb://localhost:27017/gAuth', {
useNewUrlParser: true,
}, () => {
console.log('connected to the db');
})
app.use(passport.initialize());
app.use(passport.session());
app.use('/', Routes);
app.use('/auth', Auth);
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
})