naslovnica: /api/articles dobi limit, offset in light=1 (brez content in targetUrl); home naloži prvih 30 lahkih zapisov, ostalo dolije v ozadju; determinističen vrstni red namesto Math.random, da se mreža ob dolivanju ne premeša

This commit is contained in:
folx bot
2026-08-24 17:12:15 +02:00
parent 1e9f854f26
commit 0e438b1d3c
3 changed files with 991 additions and 11 deletions
+17 -3
View File
@@ -204,9 +204,23 @@ export async function registerRoutes(
res.json(getCachedFocalPoints());
});
app.get("/api/articles", async (_req, res) => {
const articles = await storage.getArticles();
res.json(articles);
// Naslovnica je do 24.8.2026 potegnila VSEH 550 clankov skupaj s poljem
// content (1,77 MB). Zdaj sprejme limit/offset in light=1, ki odrezeta
// content in targetUrl — za kartico nista potrebna.
app.get("/api/articles", async (req, res) => {
const all = await storage.getArticles();
const offset = Math.max(0, parseInt(String(req.query.offset ?? "0")) || 0);
const limRaw = parseInt(String(req.query.limit ?? ""));
const lim = Number.isFinite(limRaw) && limRaw > 0 ? limRaw : undefined;
let out: any[] = all.slice(offset, lim ? offset + lim : undefined);
if (String(req.query.light ?? "") === "1") {
out = out.map((a: any) => {
const { content, targetUrl, ...rest } = a;
return rest;
});
}
res.set("Cache-Control", "public, max-age=60");
res.json(out);
});
app.get("/api/articles/featured", async (_req, res) => {