1
0
Files
jecnarozvrh/server.js
jzitnik-dev a942818247
All checks were successful
Remote Deploy / deploy (push) Successful in 6s
feat: Last update
2025-10-21 19:35:45 +02:00

34 lines
892 B
JavaScript

import express from "express";
import path from "path";
const app = express();
import fs from "fs/promises";
import { getCurrentInterval } from "./scheduleRules.js";
const PORT = process.env.PORT || 3000;
app.get('/', async (_, res) => {
const dataStr = await fs.readFile(path.join(process.cwd(), "db", "current.json"), "utf8");
const data = JSON.parse(dataStr);
data["status"]["currentUpdateSchedule"] = getCurrentInterval();
res.json(data);
});
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}`);
});