diff --git a/scoreboard/controllers/cli.js b/scoreboard/controllers/cli.js new file mode 100644 index 0000000..8b5f6bd --- /dev/null +++ b/scoreboard/controllers/cli.js @@ -0,0 +1,13 @@ +const exec = require('node:child_process'); + +// run the `ls` command using exec +exec('ls ./', (err, output) => { + // once the command has completed, the callback function is called + if (err) { + // log and return if we encounter an error + console.error("could not execute command: ", err) + return + } + // log the output received from the command + console.log("Output: \n", output) +}) \ No newline at end of file diff --git a/scoreboard/routes/admin.js b/scoreboard/routes/admin.js index 02875b7..595bb4e 100644 --- a/scoreboard/routes/admin.js +++ b/scoreboard/routes/admin.js @@ -17,6 +17,12 @@ router.get('/refreshMonitor', function(req, res, next) { res.send(); // send empty response }); +// Express router endpoint to do cli stuff +router.get('/cli', function(req, res, next) { + res.status(200); // Set http status code to 200 (success) + res.send(); // send empty response +}); + // ###################################################################################################################################################### // Timerendpoints // ######################################################################################################################################################