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:
+17
-3
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user