-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.js
58 lines (50 loc) · 1.17 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
global.Promise = require('bluebird')
Promise.config({
longStackTraces: true
})
const hapi = require('hapi')
const StatsD = require('hot-shots')
const env = require('./lib/env')
require('./lib/rollbar')
;(async () => {
const statsdClient = new StatsD({
host: env.STATSD_HOST,
prefix: 'badges.',
globalTags: [env.NODE_ENV]
})
const server = new hapi.Server()
server.connection({
port: env.PORT
})
server.route({
method: 'GET',
path: '/',
handler: (request, reply) => reply({ok: true})
})
await server.register([{
register: require('./lib/badges')
}, {
register: require('good'),
options: {
reporters: {
myConsoleReporter: [{
module: 'good-squeeze',
name: 'Squeeze',
args: [{
log: '*',
response: '*'
}]
}, {
module: 'good-console'
},
'stdout']
}
}
}])
server.on('response', (request, reply) => {
statsdClient.increment(`status_code.${request.response.statusCode}`)
statsdClient.timing('response_time', Date.now() - request.info.received)
})
await server.start()
console.log('server running')
})()