-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
65 lines (60 loc) · 1.27 KB
/
server.js
File metadata and controls
65 lines (60 loc) · 1.27 KB
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
require('babel-register');
var Hapi = require('hapi');
var config = require('./config');
// Create a new server
var server = new Hapi.Server();
// Setup the server with a host and port
server.connection({
port: config.app.port,
host: '0.0.0.0',
router: {
stripTrailingSlash: true
},
routes: {
cors: {
origin: ['*']
}
}
});
/*
Load all plugins and then start the server.
First: community/npm plugins are loaded
Second: project specific plugins are loaded
*/
server.register([
{
register: require('good'),
options: {
reporters: [{
reporter: require('good-console'),
events: { ops: '*', request: '*', log: '*', response: '*', 'error': '*' }
}]
}
},
{
register: require('inert')
},
{
register: require('h2o2')
},
{
register: require('./server/auth/index.js')
},
{
register: require('./server/example/index.js')
},
{
register: require('./server/base/index.js')
}
], function () {
//Start the server
if (require.main !== module) {
return;
}
server.start(function() {
//Log to the console the host and port info
console.log('Server started at: ' + server.info.uri);
});
});
// Export the server to be required elsewhere.
module.exports = server;