-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
53 lines (43 loc) · 1.1 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
const Hapi = require('hapi');
const Handler = require('./handlers/block');
class Server {
constructor(handler = null) {
this.handler = handler || new Handler();
this.hapi = Hapi.server({
port: 8000
});
this.setupRoutes();
}
setupRoutes() {
this.hapi.route({
method: 'GET',
path: '/block/{heightParam}',
handler: this.handler.getBlock.bind(this.handler)
});
this.hapi.route({
method: 'POST',
path: '/block',
handler: this.handler.postBlock.bind(this.handler)
});
this.hapi.route({
method: 'POST',
path: '/requestValidation',
handler: this.handler.requestValidation.bind(this.handler)
});
this.hapi.route({
method: 'POST',
path: '/message-signature/validate',
handler: this.handler.validate.bind(this.handler)
});
this.hapi.route({
method: 'GET',
path: '/stars/{search}:{value}',
handler: this.handler.stars.bind(this.handler)
});
}
start() {
this.hapi.start();
console.log(`Server running at ${this.hapi.info.uri}`);
}
}
module.exports = Server;