forked from microadam/exso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (34 loc) · 1.39 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
var serviceLocator = require('service-locator')()
, bunyan = require('bunyan')
, logger = bunyan.createLogger({ name: 'exso' })
, secrets =
{ webhookSecret: process.env.WEBHOOK_SECRET
, githubToken: process.env.GITHUB_TOKEN
}
, url = process.env.URL
, port = process.env.PORT || 3000
, qaWhitelist = (process.env.QA_WHITELIST || '').split(',')
, ciSkipFlag = process.env.CI_SKIP_FLAG || '[ci skip]'
, loadActions = require('./lib/action-loader')
, bootstrap = require('./bootstrap')
, createHealthRoute = require('./routes/health')
, createSetupRoute = require('./routes/setup')
serviceLocator.register('logger', logger)
serviceLocator.register('secrets', secrets)
serviceLocator.register('config', { url: url, qaWhitelist: qaWhitelist, ciSkipFlag })
loadActions(serviceLocator, function (error, actions) {
if (error) throw error
bootstrap(serviceLocator, actions, function (error, serviceLocator) {
if (error) throw error
createHealthRoute(serviceLocator)
createSetupRoute(serviceLocator)
serviceLocator.ghApi.users.get({}, function (error, user) {
if (error) throw error
serviceLocator.logger.info('Token authed as ' + user.login)
serviceLocator.register('authedUser', { username: user.login })
serviceLocator.server.listen(port, function () {
serviceLocator.logger.info('Started: ' + url + ':' + port)
})
})
})
})