initial commit
This commit is contained in:
27
server.js
Normal file
27
server.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const express = require("express");
|
||||
const path = require("path");
|
||||
const app = express();
|
||||
const fs = require("fs/promises");
|
||||
|
||||
const PORT = 3000;
|
||||
|
||||
app.get('/', (_, res) => {
|
||||
res.sendFile(path.join(__dirname, "db", "current.json"));
|
||||
});
|
||||
|
||||
app.get("/status", async (_, res) => {
|
||||
const dataStr = await fs.readFile(path.resolve("./volume/customState.json"), {encoding: "utf8"});
|
||||
const data = JSON.parse(dataStr);
|
||||
|
||||
if (data.working) {
|
||||
res.json({working: true})
|
||||
} else {
|
||||
res.json({working: data.working, message: data.message})
|
||||
}
|
||||
})
|
||||
|
||||
// TODO: Reporting errors
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server is running at http://localhost:${PORT}`);
|
||||
});
|
||||
Reference in New Issue
Block a user