This repository has been archived by the owner on Jan 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
72 lines (63 loc) · 1.51 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
'use strict';
var config = require('getconfig');
var Boom = require('boom');
var hapi = require('hapi');
var server = new hapi.Server();
server.connection(config.server);
var gatepost = require('gatepost')(config.db);
var events = require('./events')(gatepost.getClient(), server);
var plugins = [
{
register: require('hapi-auth-jwt'),
options: {}
}, {
register: require('good'),
options: {
reporters: [
{
reporter: require('good-console'),
events: {log: '*', response: '*', error: '*'}
}
]
}
}, {
register: require('./'),
options: {
jwtKey: config.jwtKey,
gatepost
}
},
{
register: require('drboom'),
options: {
plugins: [
require('drboom-pg')({}),
require('drboom-gatepost')({Boom: Boom, Gatepost: gatepost}),
require('drboom-joi')({Boom})
]
}
}
];
// Add development only plugins
if (config.isDev) {
plugins.push({
register: require('lout'),
options: {}
});
}
server.register(plugins, function (err) {
if (err) {
server.log(['error'], 'Failed to require plugins');
server.log(['error'], err.message);
throw err;
}
server.log(['startup'], 'Loaded forum plugins');
server.start(function (err) {
if (err) {
server.log(['error'], 'Failed to start forum server');
server.log(['error'], err.message);
throw err;
}
server.log(['info', 'startup'], 'Server is running on: ' + server.info.uri);
});
});