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 1
/
Copy pathindex.js
66 lines (52 loc) · 1.53 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
60
61
62
63
64
65
66
'use strict';
const Config = require('getconfig');
const Hapi = require('hapi');
const Hoek = require('hoek');
const server = new Hapi.Server();
const plugins = [{
register: require('crumb'),
options: Config.hapi.crumb
}, {
register: require('hapi-auth-cookie')
}, {
register: require('good'),
options: {
reporters: [{
reporter: require('good-console'),
events: Config.hapi.logEvents
}]
}
}];
const connection = {
host: Config.hapi.host,
port: Config.hapi.port,
router: { stripTrailingSlash: true }
};
server.connection(connection);
server.register(plugins, err => {
Hoek.assert(!err, 'Failed loading plugins: ' + err);
server.auth.strategy('session', 'cookie', Config.hapi.auth);
server.auth.default('session');
server.register({
register: require('./api'),
options: { engine: require('./engine') }
}, { routes: { prefix: '/api' } }, err => {
Hoek.assert(!err, 'Failed loading api: ' + err);
server.register({
register: require('./web'),
options: { isCached: Config.getconfig.env !== 'dev' }
}, err => {
Hoek.assert(!err, 'Failed loading web: ' + err);
server.start(err => {
Hoek.assert(!err, 'Failed starting server: ' + err);
server.log(['info', 'startup'], 'Server is running on: ' + server.info.uri);
});
});
});
});
/**
* This is for testing purposes
*/
exports.getServer = () => {
return server;
};