-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (27 loc) · 959 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
require('dotenv').config();
const express = require('express');
const app = express();
const path = require('path');
const expressSession = require('express-session');
const indexRouter = require('./routes/index');
const userRouter = require('./routes/users')
const passport = require('passport');
app.set('views',path.join(__dirname,'views'));
app.set('view engine','ejs');
app.use(expressSession({
resave:false,
saveUninitialized:false,
secret:process.env.SECRET
}))
app.use(passport.initialize());
app.use(passport.session());
passport.serializeUser(userRouter.serializeUser());
passport.deserializeUser(userRouter.deserializeUser());
app.use(express.urlencoded({extended:false}));
app.use(require('morgan')('tiny'))
app.use(express.static(path.join(__dirname,'public')));
app.use('/',indexRouter);
app.use('/users',userRouter);
app.listen(process.env.PORT, ()=>{
console.log(`Server is running on the port ${process.env.PORT}.`);
})