-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (30 loc) · 942 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
require('dotenv').config();
const express = require('express');
const exphbs = require('express-handlebars');
const session = require('express-session');
const passport = require('passport');
const { join } = require('path');
const app = express();
const PORT = process.env.PORT || 5000;
// handlebars
app.engine('.hbs', exphbs({ defaultLayout: 'main', extname: '.hbs' }));
app.set('view engine', '.hbs');
// init passport google strategy
require('./config/passport')(passport);
// session middlware
app.use(session({
secret: process.env.SECRET_SESSION,
resave: false,
saveUninitialized: false,
}));
// passport middleware
app.use(passport.initialize());
app.use(passport.session());
// static
app.use(express.static(join(__dirname, 'public')));
// routes
app.use('/', require('./routes/index'));
app.use('/auth', require('./routes/auth'));
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
})