aboutsummaryrefslogtreecommitdiff
path: root/api/routes/getNodeInfo
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-06-10 05:08:59 +0300
committerkaotisk <kaotisk@arching-kaos.org>2024-06-10 05:08:59 +0300
commitae9726f747b2ec3e5805d03ef04ad47cb7628315 (patch)
treecebc25f70264532a3b6276c4c7acc159d4703d2e /api/routes/getNodeInfo
parentab7cbfd693c6251f6c1bc427eb9a65b1dbee159e (diff)
downloadarching-kaos-tools-ae9726f747b2ec3e5805d03ef04ad47cb7628315.tar.gz
arching-kaos-tools-ae9726f747b2ec3e5805d03ef04ad47cb7628315.tar.bz2
arching-kaos-tools-ae9726f747b2ec3e5805d03ef04ad47cb7628315.zip
Refactoring
Diffstat (limited to 'api/routes/getNodeInfo')
-rw-r--r--api/routes/getNodeInfo/index.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/api/routes/getNodeInfo/index.js b/api/routes/getNodeInfo/index.js
index 877b55a..d99382a 100644
--- a/api/routes/getNodeInfo/index.js
+++ b/api/routes/getNodeInfo/index.js
@@ -2,7 +2,7 @@ const { spawn } = require('child_process');
const akLogMessage = require('../../lib/akLogMessage');
module.exports = (req, res) => {
- akLogMessage('INFO', `Incoming from [${req.socket._peername.address}]:${req.socket._peername.port} @ ${req.get('host')}${req._parsedOriginalUrl.pathname}`);
+ akLogMessage('INFO', `Incoming from [${req.connection.remoteAddress}]:${req.socket._peername.port} @ ${req.url}`);
const command = spawn("ak-config", ["--get-published"]);
var buffer = "";
command.stdout.on("data", data => {
@@ -10,15 +10,16 @@ module.exports = (req, res) => {
});
command.stderr.on("data", data => {
- console.log(`stderr: ${data}`);
+ console.log(`stderr: ${data}`);
});
command.on('error', (error) => {
- console.log(`error: ${error.message}`);
+ console.log(`error: ${error.message}`);
});
command.on("close", code => {
- res.send(JSON.parse(buffer));
- console.log(`child process exited with code ${code}`);
+ res.writeHead(200, { 'Content-Type': 'application/json'});
+ res.end(buffer);
+ console.log(`child process exited with code ${code}`);
});
};