feat: Custom schedule rules
All checks were successful
Remote Deploy / deploy (push) Successful in 4s
All checks were successful
Remote Deploy / deploy (push) Successful in 4s
This commit is contained in:
16
server.js
16
server.js
@@ -2,11 +2,19 @@ const express = require("express");
|
||||
const path = require("path");
|
||||
const app = express();
|
||||
const fs = require("fs/promises");
|
||||
const { getCurrentInterval } = require("./scheduleRules");
|
||||
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
app.get('/', (_, res) => {
|
||||
res.sendFile(path.join(__dirname, "db", "current.json"));
|
||||
app.get('/', async (_, res) => {
|
||||
const dataStr = fs.readFile(path.join(__dirname, "db", "current.json"));
|
||||
const data = JSON.parse(dataStr);
|
||||
|
||||
data["status"] = {
|
||||
currentUpdateSchedule: getCurrentInterval(),
|
||||
};
|
||||
|
||||
res.json(data);
|
||||
});
|
||||
|
||||
app.get("/status", async (_, res) => {
|
||||
@@ -14,9 +22,9 @@ app.get("/status", async (_, res) => {
|
||||
const data = JSON.parse(dataStr);
|
||||
|
||||
if (data.working) {
|
||||
res.json({working: true})
|
||||
res.json({ working: true })
|
||||
} else {
|
||||
res.json({working: data.working, message: data.message})
|
||||
res.json({ working: data.working, message: data.message })
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user