From d5ffe18497daa31ddd738118c52ed397097d2413 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Wed, 4 Sep 2024 12:01:53 -0600 Subject: [PATCH] Doing stuff --- index.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 4075775..9e2c85e 100644 --- a/index.js +++ b/index.js @@ -13,7 +13,7 @@ app.set('trust proxy', true); app.use((req, res, next) => { // Request logger for debugging - console.log(`[${new Date().toLocaleString()}] ${req.method} ${req.path} from ${req.ip} with ${JSON.stringify(req.body)}`); + //console.log(`[${new Date().toLocaleString()}] ${req.method} ${req.path} from ${req.ip} with ${JSON.stringify(req.body)}`); next(); }); @@ -68,7 +68,6 @@ app.post("/api/send/:jobid/:id/", (req, res) => { }); return; } - console.log("sent data: " + req.body) if (stats.open == true) { socket.send(req.body.data); } else { @@ -102,15 +101,24 @@ app.get("/api/poll/:jobid/:id", (req, res) => { } }) -app.delete("/api/close/:jobid/:id", async (req, res) => { +app.delete("/api/close/:jobid/:id", (req, res) => { var id = req.params.id; - await ws_[id].connection.terminate(); - await delete ws_[id]; + if (ws_[id]) ws_[id].connection.terminate(); + delete ws_[id]; res.send({ success: true }); }) +// Catch rejections and exceptions +process.on('unhandledRejection', (err) => { + console.error(err); +}); + +process.on('uncaughtException', (err) => { + console.error(err); +}); + app.listen(PORT, () => { console.log('server started'); });