-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
31 lines (21 loc) · 976 Bytes
/
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
const ExplorerServer = require('./src/ExplorerServer');
const RestServer = require('./src/rest');
const SocketServer = require('./src/SocketServer');
var restServer; // eslint-disable-line
var socketServer; // eslint-disable-line
var explorerServer = new ExplorerServer((error) => {
var port = process.env.REST_PORT || 3000;
var socketPort = process.env.SOCKET_PORT || 3001;
if (error) {
return console.error(error);
}
// Start listening for new blocks from the block chain.
explorerServer.start();
// Create a new instance of the rest server.
restServer = new RestServer(explorerServer.api, port);
// Create a new socket server and pass a reference to the express server to reuse it.
socketServer = new SocketServer(restServer.app, socketPort);
// Pass a reference of the socket server to the explorer server so it can broadcast events about new blocks.
explorerServer.socketServer = socketServer;
});
module.exports = explorerServer;