forked from Adamant-im/adamant-tradebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
39 lines (34 loc) · 840 Bytes
/
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
/**
* @description http watched DB tables
*/
const express = require('express');
const app = express();
const config = require('./modules/configReader');
const log = require('./helpers/log');
const port = config.debug_api;
const db = require('./modules/DB');
if (port) {
app.get('/db', (req, res) => {
const tb = db[req.query.tb].db;
if (!tb) {
res.json({
err: 'tb not find',
});
return;
}
tb.find().toArray((err, data) => {
if (err) {
res.json({
success: false,
err,
});
return;
}
res.json({
success: true,
result: data,
});
});
});
app.listen(port, () => log.info(`${config.notifyName} debug server is listening on http://localhost:${port}. F. e., http://localhost:${port}/db?tb=systemDb.`));
}