-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
31 lines (26 loc) · 866 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
require('dotenv').config();
const express = require('express');
const session = require('cookie-session');
const helmet = require('helmet');
const hpp = require('hpp');
const csurf = require('csurf');
const passport = require('./middleware/passport');
const app = express();
const port = process.env.PORT || 5000;
const isProduction = process.env.NODE_ENV === 'production';
/* Register Middleware */
app.use(helmet());
app.use(hpp());
app.use(session({
name: process.env.SESSION_NAME,
secret: process.env.SESSION_SECRET,
secure: isProduction,
expires: new Date(Date.now() + 24 * 60 * 60 * 1000) // 24 hrs
}));
app.use(csurf());
app.use(passport.initialize());
/* Register Routes */
const authRoutes = require('./routes/auth');
app.use('/auth', authRoutes);
app.listen(port, () => console.log(`Listening on port ${port}`));
module.exports = app;