1
0

feat: v2
All checks were successful
Remote Deploy / deploy (push) Successful in 1m11s

Support of teacher absence format: "za Vn zastupuje Jk"
This commit is contained in:
2026-01-04 14:02:10 +01:00
parent 0325ce1815
commit 6b383b1af4
7 changed files with 95 additions and 12 deletions

View File

@@ -19,6 +19,7 @@ import fs from "fs/promises";
import { getCurrentInterval } from "./scheduleRules.js";
import bodyParser from "body-parser";
const VERSIONS = ["v1", "v2"];
const PORT = process.env.PORT || 3000;
globalThis.File = class File {};
@@ -50,6 +51,23 @@ app.get('/versioned/v1', async (_, res) => {
res.json(data);
});
VERSIONS.forEach((version) => {
app.get(`/versioned/${version}`, async (_, res) => {
try {
const filePath = path.join(process.cwd(), "db", `${version}.json`);
const dataStr = await fs.readFile(filePath, "utf8");
const data = JSON.parse(dataStr);
data.status.currentUpdateSchedule = getCurrentInterval();
res.json(data);
} catch (err) {
console.error(err);
res.status(500).json({ error: "Failed to load version data" });
}
});
});
app.get("/status", async (_, res) => {
const dataStr = await fs.readFile(path.resolve("./volume/customState.json"), {encoding: "utf8"});
const data = JSON.parse(dataStr);