-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (29 loc) · 1.09 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
const express = require('express')
const app = express()
const domain = require('domain')
const path = require('path')
const {authenticationMiddleware, authenticationDevMiddleware} = require('@first-lego-league/ms-auth')
const {correlateSession} = require('@first-lego-league/ms-correlation')
const {Logger} = require('@first-lego-league/ms-logger')
const appPort = process.env.PORT || 3000
const logger = Logger()
logger.setLogLevel(process.env.LOG_LEVEL || logger.LOG_LEVELS.DEBUG)
if (process.env.DEV) {
app.use(authenticationDevMiddleware())
} else {
app.use(authenticationMiddleware)
}
// App files
app.use('/', express.static(path.resolve(__dirname, 'dist/client')))
// Design files
app.use('/design', express.static(path.resolve(__dirname, 'node_modules/@first-lego-league/user-interface/current/assets')))
// So every route will end up at the angular app
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'dist/client/index.html'));
});
app.listen(appPort, () => {
domain.create().run(() => {
correlateSession()
logger.info('Server started on port ' + appPort)
})
})