forked from pranavtharoor/prometheus-8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
41 lines (34 loc) · 1.08 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
const path = require('path');
require('dotenv').config({ path: path.join(__dirname, '.env') });
const express = require('express');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const session = require('express-session');
const redisStore = require('./config/redis')(session);
const routes = require('./routes');
const views = require('./routes/views');
const responseFormat = require('./utils/responseFormat');
const sessionSecret = require('./config/session').secret;
const app = express();
app.use(logger('dev'));
app.use(
session({
resave: false,
saveUninitialized: false,
secret: sessionSecret,
store: redisStore,
cookie: { maxAge: 604800000 }
})
);
app.use(express.static('public'));
app.use(cookieParser('secret'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(responseFormat);
app.use('/api', routes);
app.use('/', views);
const port = process.env.PORT || 3000;
app.listen(port, err => {
console.log(err || 'Listening on port ' + port);
});