-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (32 loc) · 1.01 KB
/
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 session = require('express-session');
const morgan = require('morgan');
const mongoose = require('mongoose');
const passport = require('passport');
const port = process.env.PORT | 3000;
const app = express();
passport.use(require('./auth').init());
app.use(express.urlencoded({ extended: true }));
app.use(express.static(__dirname + '/public'));
//app.use(helmet());
app.use(session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: true,
cookie: { maxAge: 24 * 60 * 60 * 1000} // 1 Day
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(morgan('dev'));
app.use('/', require('./routes/main.js'));
app.use('/admin', require('./routes/admin.js'));
app.use('/api', require('./routes/api.js'));
app.set('view engine', 'ejs');
mongoose.connect(process.env.DBURI, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
app.listen(port, async () => {
console.log(`Listening on port ${port}`);
});