-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
71 lines (58 loc) · 1.37 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
'use strict';
const Hapi = require('hapi');
var StatusService = require('./services/statusService');
const server = new Hapi.Server();
server.connection({
host: '0.0.0.0',
port: 3000,
labels: ['api']
});
server.connection({
host: '0.0.0.0',
port: 3001,
labels: ['status']
});
const api = server.select('api');
server.register(require('h2o2'), (err) => {
if (err) {
console.error('Failed to load h2o2');
}
});
server.register(require('./plugin/registerNewTentacle.js'), (err) => {
if (err) {
console.error('Failed to load plugin:', err);
}
});
server.register(require('./plugin/statusChanged.js'), function (err) {
if (err) {
console.error('Failed to load statusChanged plugin');
}
});
server.register(require('inert'), function (err){
if (err){
console.error('Failed to load inert plugin');
}
api.route({
method: 'GET',
path: '/{param*}',
config: {
auth: false,
handler: {
directory: {
path: 'view',
listing: true
}
}
}
});
});
api.route({
method: 'GET',
path: '/status',
handler: function (request, reply) {
reply(StatusService.getAllTentacles());
}
});
server.start(() => {
console.log('Server running at:', api.info.uri);
});