feat(routes): status route
This commit is contained in:
16
src/index.js
16
src/index.js
@@ -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, () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user