-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (30 loc) · 949 Bytes
/
index.js
File metadata and controls
43 lines (30 loc) · 949 Bytes
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
const express = require('express');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const path = require('path');
const i18n = require('i18n');
const languageCookie = require('./lib/middleware/language-cookie');
i18n.configure({
locales: ['en-US', 'sv-SE'],
directory: path.join(__dirname, 'locales'),
objectNotation: true
});
const routes = require('./routes');
const port = process.env.PORT || 3000;
const app = express();
if (process.env.NODE_ENV === 'production') {
app.set('trust proxy', 1); // trust first proxy
}
app
.use(bodyParser.json({ type: '*/json' }))
.use(express.static(path.join(__dirname, 'public')))
.use(cookieParser())
.use(i18n.init)
.use(languageCookie)
.set('views', path.join(__dirname, 'views'))
.set('view engine', 'pug')
.use('/', routes)
.listen(port, () => {
console.log(`Listening on ${port}`);
})
;