-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
41 lines (30 loc) · 1.02 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
const DEFAULT_PORT = 3002
const express = require('express')
const cors = require('cors')
const { correlationMiddleware } = require('@first-lego-league/ms-correlation')
const { Logger, loggerMiddleware } = require('@first-lego-league/ms-logger')
const { version: projectVersion } = require('./package.json')
const { rankingsRouter } = require('./lib/rankings_router')
const port = process.env.PORT || DEFAULT_PORT
const app = express()
const logger = new Logger()
logger.info(`-------------------- rankings version ${projectVersion} startup --------------------`)
app.use(correlationMiddleware)
app.use(loggerMiddleware)
app.use(cors())
app.use(rankingsRouter)
app.listen(port, () => {
logger.info(`Rankings service listening on port ${port}`)
})
process.on('SIGINT', () => {
logger.info('Process received SIGINT: shutting down')
process.exit(130)
})
process.on('uncaughtException', err => {
logger.fatal(err.message)
process.exit(1)
})
process.on('unhandledRejection', err => {
logger.fatal(err.message)
process.exit(1)
})