-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.js
33 lines (25 loc) · 830 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
'use strict';
const path = require('path');
const express = require('express');
const app = express();
const port = process.env.PORT || 3000;
const bodyParser = require('body-parser');
const helmet = require('helmet');
const cookieSession = require('cookie-session');
const mongoose = require('mongoose');
const config = require('./config');
const { name, keys } = config.session;
const { url } = config.mongodb;
const routes = require('./routes');
mongoose.connect(url, {useNewUrlParser: true, useUnifiedTopology: true });
app.disable('x-powered-by');
app.set('view engine', 'ejs');
app.use('/public', express.static(path.join(__dirname, 'public')));
app.use(helmet());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieSession({
name: name,
keys: keys
}));
app.use('/', routes);
app.listen(port);