-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
executable file
·44 lines (37 loc) · 1.2 KB
/
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
43
44
'use strict'
require('dotenv').config()
// eslint-disable-next-line import/newline-after-import
const { KthAppinsights } = require('@kth/appinsights')
KthAppinsights.init({ name: 'kursinfo-web' })
const log = require('@kth/log')
const config = require('./server/configuration').server
const server = require('./server/server')
const packageFile = require('./package.json')
// catches uncaught exceptions
process.on('uncaughtException', err => {
log.error('APPLICATION EXIT - uncaught exception in ', packageFile.name)
log.error('Uncaught Exception', { err })
process.exit(1)
})
// catches unhandled promise rejections
process.on('unhandledRejection', reason => {
// This line below provokes an uncaughtException and will be caught few lines
// above
log.error(`unhandledRejection ${packageFile.name}`, reason)
// throw reason
})
/* ****************************
* ******* SERVER START *******
* ****************************
*/
// Exports a promise to use in integration tests
module.exports = server.start({
useSsl: config.useSsl,
pfx: config.ssl.pfx,
passphrase: config.ssl.passphrase,
key: config.ssl.key,
ca: config.ssl.ca,
cert: config.ssl.cert,
port: config.port,
logger: log,
})