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) => {
|
||||
// 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');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue