-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.js
50 lines (40 loc) · 1.3 KB
/
app.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
'use strict'
const express = require('express')
const app = express()
const config = require('./config')
const promclient = require('prom-client')
if (config.zmq_url !== '') {
let zmqInfo = require('./zmq/zmq.js')(promclient, config)
let api = require('./zmq/api.js')(config)
app.get('/getSeenButNotConfirmed', function (req, res) {
api.getSeenButNotConfirmed((data) => {
res.send((data))
})
})
app.get('/pruneDb', function (req, res) {
api.pruneDB((data) => {
res.send((data))
})
})
app.get('/getHistogram', function (req, res) {
api.getHistogram((data) => {
res.send((data))
})
})
}
if (config.market_info_flag) {
let marketInfo = require('./marketInfo/marketInfoSocketRC.js')(promclient, config)
}
let nodeInfo = require('./nodeInfo/nodeInfo.js')(promclient, config)
let neighborInfo = require('./neighborInfo/neighborInfo.js')(promclient, config)
app.get('/metrics', async (req, res) => {
const [nodeResults,
neighborResults] = await Promise.all([
nodeInfo.getNodeInfo(),
neighborInfo.getNeighborInfo()
])
res.end(promclient.register.metrics())
})
app.listen(config.bind_port, config.bind_address, () => {
console.log('Listening on:', config.bind_port)
})