feat: Update API versioning and parser handling for improved schedule updates and error management

This commit is contained in:
2026-10-19 23:29:35 +03:00
parent 85c5baa3e5
commit 68f9b95090
10 changed files with 32 additions and 18 deletions

View File

@@ -66,8 +66,9 @@ app.use("/api", (_req, res, next) => {
// 6 — the timetable carries the group's exams and credits from other catalog documents;
// 7 — /api/diagnostics, cells the parser could not read with confidence;
// 8 — /api/ready, and `ready` in /api/health;
// 9 — a request limit on /api (429 too_many_requests), a 30 s time limit (504 timeout), security headers.
const API_VERSION = 9;
// 9 — a request limit on /api (429 too_many_requests), a 30 s time limit (504 timeout), security headers;
// 10 — parserVersion in /api/catalog.
const API_VERSION = 10;
/**
* What the server still waits for before it answers from memory: the catalog, the week table
@@ -221,7 +222,8 @@ app.get("/api/diagnostics", async (req, res, next) => {
});
app.get("/api/catalog", async (req, res, next) => {
try {
res.json(await getCatalog(req.query.refresh === "1"));
// The parser version lets the PWA re-read schedules it saved from an older parser.
res.json({ ...(await getCatalog(req.query.refresh === "1")), parserVersion: PARSER_VERSION });
} catch (e) {
next(e);
}