-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
46 lines (40 loc) · 1.15 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require('dotenv').config();
const port = process.env.PORT;
const mongoURL = process.env.MONGODB_URL;
let express = require('express');
let app = express();
let session = require('express-session');
let lusca = require('lusca');
app.use(session({
secret: 'supercauliflowerexplosions123$567*9*',
resave: true,
saveUninitialized: true
}));
app.use(lusca({
// csrf: true,
// csp: {policy: {
// 'default-src': '\'self\''
// }},
xframe: 'SAMEORIGIN',
p3p: 'ABCDEF',
hsts: {maxAge: 31436000, includeSubDomains: true, preload: true},
xssProtection: true,
nosniff: true
}));
let bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
app.set('views', 'views/');
app.set('view engine', 'ejs');
app.use('/public', express.static('public'));
let morgan = require('morgan');
app.use(morgan('dev'));
let router = require('./modules/router.js');
let mongodbClient = require('mongodb').MongoClient;
mongodbClient.connect(mongoURL).then((db) => {
router(app, db);
app.listen(port);
console.info('Listening on port ' + port);
}).catch((err) => {
console.error('Error connecting to db: ' + err);
});