-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
40 lines (32 loc) · 905 Bytes
/
server.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 express = require('express');
const app = express();
const passport = require('passport');
const flash = require('express-flash');
const session = require('express-session');
const methodOverride = require('method-override');
const port = process.env.PORT
// db
require('./config/db/mongoose');
// routes
const index = require('./routes/index');
const user = require('./routes/user');
app.set('view engine', 'ejs');
app.use(express.urlencoded( { extended : false }));
app.use(flash());
app.use(session({
secret : process.env.SESSION_SECRET,
resave : false,
saveUninitialized : false
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(methodOverride('_method'));
// routes use
app.use('/', index);
app.use('/users', user);
app.get('*',(req, res) => {
res.render('404');
});
app.listen(port, () => {
console.log(`Server started on port ${port}`);
});