-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (31 loc) · 1.04 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
39
40
41
42
43
44
45
const express = require('express');
const cors = require('cors');
const path = require('path');
const bodyParser = require('body-parser');
const cookieParser = require("cookie-parser");
const config = require('./startup/config');
const winston = require('winston');
var expressSession = require('express-session')
const err = require('./middleware/errors');
const mainRoutes = require('./routes/main-routes');
const app = express();
require('./startup/logging')();
app.set('trust proxy', 1)
app.use(expressSession({
secret: 'x159951A!',
resave: true,
saveUninitialized: true,
cookie: { maxAge: 2 * 24 * 60 * 60 * 1000 }
}))
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(cors());
app.use(bodyParser.json());
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(mainRoutes.routes);
app.use(err);
app.listen(config.port, () => winston.info('App is listening on url http://localhost:' + config.port));