Add server/status.js
Add initial status API backend
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
const http = require('http');
|
||||||
|
|
||||||
|
const port = 8080;
|
||||||
|
|
||||||
|
const status = {
|
||||||
|
service: 'running',
|
||||||
|
bitcoinNode: 'not connected',
|
||||||
|
wallet: 'not configured',
|
||||||
|
labels: 0,
|
||||||
|
transactions: 0,
|
||||||
|
lastScan: 'never'
|
||||||
|
};
|
||||||
|
|
||||||
|
const server = http.createServer((req, res) => {
|
||||||
|
if (req.url === '/api/status') {
|
||||||
|
res.writeHead(200, {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
});
|
||||||
|
|
||||||
|
res.end(JSON.stringify(status));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
res.writeHead(404);
|
||||||
|
res.end('Not found');
|
||||||
|
});
|
||||||
|
|
||||||
|
server.listen(port, () => {
|
||||||
|
console.log(`Status API listening on port ${port}`);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user