From 5e7a0576e5ca495225c1cc97e5d5404fc3f10a0b Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Wed, 4 Sep 2024 08:15:52 -0600 Subject: [PATCH] Do thing to fix thing --- index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/index.js b/index.js index 695a3d1..f54cd37 100644 --- a/index.js +++ b/index.js @@ -29,6 +29,7 @@ app.put('/api/connect/:jobid', (req, res) => { ws_[id].connection.on('close', function() { if (ws_[id]) { ws_[id].connection.terminate(); + delete ws_[id]; } }) ws_[id].open = false; @@ -44,6 +45,13 @@ app.put('/api/connect/:jobid', (req, res) => { }); app.post("/api/send/:jobid/:id/", (req, res) => { + if (!ws_[req.params.id]) { + res.status(404).send({ + success: false, + message: "Invalid ID" + }); + return; + } if (ws_[req.params.id].jobid !== req.params.jobid) { res.status(401).send({ success: false, @@ -76,6 +84,13 @@ app.post("/api/send/:jobid/:id/", (req, res) => { }) app.get("/api/poll/:jobid/:id", (req, res) => { + if (!ws_[req.params.id]) { + res.status(404).send({ + success: false, + message: "Invalid ID" + }); + return; + } if (ws_[req.params.id].jobid !== req.params.jobid) { res.status(401).send({ success: false,