-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
47 lines (34 loc) · 1.06 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
require('dotenv').config();
const path = require('path');
const express = require('express');
const bodyParser = require('body-parser');
const session = require('express-session')
const csurf = require('csurf');
const cookieParser = require('cookie-parser');
const helmet = require('helmet');
const gameRoutes = require('./routes/game');
const errorController = require('./controllers/error');
const app = express();
app.set('view engine', 'ejs');
app.set('views', 'views');
app.set('trust proxy', 1);
app.use(helmet({
contentSecurityPolicy: false
}));
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(session({
secret: 'onenation',
cookie: { maxAge: 60000, sameSite: 'strict'},
resave: true,
saveUninitialized: false,
}));
app.use(cookieParser());
app.use(csurf({ cookie: false }));
app.use('/', gameRoutes);
app.use(errorController.get404);
// Start server
const port = process.env.PORT || 3000;
app.listen(port);
console.log(`Listening on port ${port}`);