From 2e45e945cb7baa3131430c9c069f9ba9d4ee77b9 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Thu, 29 Feb 2024 08:04:42 +0200 Subject: Refactoring --- api/routes/getAkid/index.js | 30 ------------------------------ api/routes/getNodeInfo/index.js | 30 ++++++++++++++++++++++++++++++ api/routes/index.js | 4 ++-- 3 files changed, 32 insertions(+), 32 deletions(-) delete mode 100644 api/routes/getAkid/index.js create mode 100644 api/routes/getNodeInfo/index.js diff --git a/api/routes/getAkid/index.js b/api/routes/getAkid/index.js deleted file mode 100644 index 34426e5..0000000 --- a/api/routes/getAkid/index.js +++ /dev/null @@ -1,30 +0,0 @@ -const { spawn } = require('child_process'); - -/* - * Gets the local latest zblock - * - * Returns: - * - JSON object - * { zlatest: "Qm..." } - * - */ -module.exports = (req, res) => { - const command = spawn("ak-config", ["get-published"]); - var buffer = ""; - command.stdout.on("data", data => { - buffer = buffer + data; - }); - - command.stderr.on("data", data => { - console.log(`stderr: ${data}`); - }); - - command.on('error', (error) => { - console.log(`error: ${error.message}`); - }); - - command.on("close", code => { - res.send(JSON.parse(buffer)); - console.log(`child process exited with code ${code}`); - }); -}; diff --git a/api/routes/getNodeInfo/index.js b/api/routes/getNodeInfo/index.js new file mode 100644 index 0000000..34426e5 --- /dev/null +++ b/api/routes/getNodeInfo/index.js @@ -0,0 +1,30 @@ +const { spawn } = require('child_process'); + +/* + * Gets the local latest zblock + * + * Returns: + * - JSON object + * { zlatest: "Qm..." } + * + */ +module.exports = (req, res) => { + const command = spawn("ak-config", ["get-published"]); + var buffer = ""; + command.stdout.on("data", data => { + buffer = buffer + data; + }); + + command.stderr.on("data", data => { + console.log(`stderr: ${data}`); + }); + + command.on('error', (error) => { + console.log(`error: ${error.message}`); + }); + + command.on("close", code => { + res.send(JSON.parse(buffer)); + console.log(`child process exited with code ${code}`); + }); +}; diff --git a/api/routes/index.js b/api/routes/index.js index 174ed66..cb3c584 100644 --- a/api/routes/index.js +++ b/api/routes/index.js @@ -13,7 +13,7 @@ const receiveZChain = require('./receiveZChain'); const getZblock = require('./getZblock'); const getMrk = require('./getMrk'); const getTr = require('./getTr'); -const getAkid = require('./getAkid'); +const getNodeInfo = require('./getNodeInfo'); const getPeers = require('./getPeers'); const getInnerIPFSContent = require('./getInnerIPFSContent'); const corsOptions = { @@ -41,7 +41,7 @@ router.route(settings.URL_PREFIX+'/zchain').get(getZChain); // Returns latest zblock from node's local chain router.route(settings.URL_PREFIX+'/zlatest').get(getZLatest); // Returns local node's info -router.route(settings.URL_PREFIX+'/node_info').get(getAkid); +router.route(settings.URL_PREFIX+'/node_info').get(getNodeInfo); // Returns local node's peers router.route(settings.URL_PREFIX+'/peers').get(getPeers); // Returns content -- cgit v1.2.3