Doing stuff
This commit is contained in:
parent
c54c3212e2
commit
d5ffe18497
18
index.js
18
index.js
|
@ -13,7 +13,7 @@ app.set('trust proxy', true);
|
||||||
|
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
// Request logger for debugging
|
// 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();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -68,7 +68,6 @@ app.post("/api/send/:jobid/:id/", (req, res) => {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("sent data: " + req.body)
|
|
||||||
if (stats.open == true) {
|
if (stats.open == true) {
|
||||||
socket.send(req.body.data);
|
socket.send(req.body.data);
|
||||||
} else {
|
} 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;
|
var id = req.params.id;
|
||||||
await ws_[id].connection.terminate();
|
if (ws_[id]) ws_[id].connection.terminate();
|
||||||
await delete ws_[id];
|
delete ws_[id];
|
||||||
res.send({
|
res.send({
|
||||||
success: true
|
success: true
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Catch rejections and exceptions
|
||||||
|
process.on('unhandledRejection', (err) => {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('uncaughtException', (err) => {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
app.listen(PORT, () => {
|
||||||
console.log('server started');
|
console.log('server started');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue