feat(routes): status route

This commit is contained in:
Stefan080106
2023-05-24 21:27:29 +02:00
parent 63dfafe329
commit a6d8617ac7

View File

@@ -195,6 +195,22 @@ app.get('/depesche', async (req, res) => {
app.get("/health", (req, res) => { app.get("/health", (req, res) => {
res.send("ok"); 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); const httpsServer = https.createServer(credentials, app);
httpsServer.listen(PORT, () => { httpsServer.listen(PORT, () => {