-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
58 lines (49 loc) · 1.11 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
'use strict';
const Hapi = require('hapi');
const Inert = require('inert');
const socketConnection = require('./server_sockets/socket');
const server = new Hapi.Server();
server.connection({
port: 5000
});
server.register([Inert], function (err) {
if (err) {
throw err;
}
server.route({
method: 'GET',
path: '/{path*}',
config: {
auth: false,
cache: {
expiresIn: 24 * 60 * 60 * 1000,
privacy: 'public'
}
},
handler: {
directory: {
path: __dirname + '/.static_client',
listing: false,
index: true
}
}
});
// Example api call
server.route({
method: 'GET',
path: '/api/call',
handler: function (request, reply) {
reply({
message: 'Hello!'
})
}
});
});
server.start((err) => {
if (err) {
throw err;
}
socketConnection.start();
console.log('Server running at:', server.info.uri);
});
module.exports = server;