-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
59 lines (51 loc) · 1.19 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
59
'use strict';
var Hapi = require('hapi')
var Bell = require('bell')
var Chairo = require('chairo')
var Cookie = require('hapi-auth-cookie')
var Nes = require('nes')
var Good = require('good')
var GoodConsole = require('good-console')
var Services = require('./lib/services');
// Options for our hapi plugins.
var opts = {
server: {
port: Number(process.env.SERVICE_PORT || 3030),
host: process.env.SERVICE_HOST
},
chairo: {
timeout: 2000,
secure: true,
log: 'level:info'
},
good: {
opsInterval: 1000,
reporters: [{reporter: GoodConsole, events: {log: '*', response: '*'}}]
}
}
// Create our server.
var server = new Hapi.Server({debug: {request: ['error']}})
server.connection(
{
host: opts.server.host,
port: opts.server.port
}
)
// Declare our Hapi plugin list.
var plugins = [
{register: Bell},
{register: Cookie},
{register: Chairo, options: opts.chairo},
{register: Nes},
{register: Good, options: opts.good}
]
server.register(plugins,
function (err) {
if (err) {
throw err;
}
server.seneca.use(Services)
server.start(function () {
console.log('listening on port: ' + process.env.SERVICE_PORT);
});
});