diff --git a/index.js b/index.js index 86facda..580d5ff 100644 --- a/index.js +++ b/index.js @@ -731,6 +731,19 @@ app.get('/api/v1', (req, res) => { // Backwards compatibility with TandmX cause }); }); +// Management Routes (Like restarting the server) +app.post("/api/v1/manage/restart", (req, res) => { + // Check Authorization header against process.env.MANAGEMENT_AUTH + if (req.headers.authorization !== (process.env.MANAGEMENT_AUTH || crypto.randomBytes(32).toString('hex'))) { // Default to random in case we forget to configure it + res.status(401).send("Unauthorized"); + return; + } + res.status(200).send("Restarting server..."); + setTimeout(() => { + process.exit(0); + }, 500); +}); + // Start server app.listen(port, () => { console.log(`Listening on port ${port}`);