-
Notifications
You must be signed in to change notification settings - Fork 5
/
server.js
executable file
·42 lines (37 loc) · 985 Bytes
/
server.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
/*
* Do appinsights first as it does some magic instrumentation work, i.e. it affects other 'require's
* In particular, applicationinsights automatically collects bunyan logs
*/
import { initialiseAppInsights } from './server/utils/azure-appinsights'
initialiseAppInsights()
/** @type {any} */
const knex = require('knex')
const knexfile = require('./knexfile')
const app = require('./server/index').default
const log = require('./log')
const selectSql = message => {
if (message.sql) {
return message.sql
}
if (message.length && message.length >= 1) {
return message[0].sql
}
return { knex: message }
}
const init = {
...knexfile,
log: {
debug(message) {
log.debug(selectSql(message))
},
},
debug: true,
}
log.debug('Migration start')
const knex1 = knex(init)
knex1.migrate.latest().then(() => {
log.debug('Migration finished')
app.listen(app.get('port'), () => {
log.info(`Server listening on port ${app.get('port')}`)
})
})