-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
42 lines (35 loc) · 908 Bytes
/
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
const express = require('express');
const nunjucks = require('nunjucks');
const session = require('express-session');
const indexRouter = require('./routes/index-route');
const app = express();
// nunjucks config
nunjucks.configure('views', {
autoescape: true,
express: app
});
// init static files
// this files contain css and js for views
app.use(express.static('public'))
// express-session config
app.use(
session({
name: 'sid',
saveUninitialized: false,
resave: false,
secret: 'sssh, quiet! it\'s a secret!',
cookie: {
maxAge: 1000 * 60 * 60 * 2,
sameSite: true,
secure: process.env.NODE_ENV === 'production'
}
})
)
// test route
app.get('/index', (req, res) => {
res.send('App works');
});
// index route
app.use('', indexRouter);
var PORT = process.env.PORT || 8080;
app.listen(PORT, () => { console.log(`Server started at port ${PORT}`) });