From a6d8617ac777b36326fed9c28475fecbb3a70a33 Mon Sep 17 00:00:00 2001 From: Stefan080106 Date: Wed, 24 May 2023 21:27:29 +0200 Subject: [PATCH] feat(routes): status route --- src/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/index.js b/src/index.js index 50f08af..181dfb7 100644 --- a/src/index.js +++ b/src/index.js @@ -195,6 +195,22 @@ app.get('/depesche', async (req, res) => { app.get("/health", (req, res) => { res.send("ok"); }); + +app.post("/states/status", (req, res) => { + if (req.query.accesskey != config.accesskey) { + return res.status(401).json({ + "success": false, + "error": "Unauthorized" + }); + } + // Append request body to file + fs.appendFileSync(cacheFolder + "status.json", JSON.stringify(req.body) + "\n"); + + res.json({ + "success": true + }); +}); + const httpsServer = https.createServer(credentials, app); httpsServer.listen(PORT, () => {