SPB Git

Repository Public

route.ts 880 B 18 lines typescript

1import { filmsByIds, listFilms } from "@/lib/films";2import { json, localeOf } from "@/lib/api";34/** GET /api/films — published films, newest first, cursor pagination. */5export async function GET(req: Request) {6  const url = new URL(req.url);7  const locale = localeOf(url);8  const ids = url.searchParams.get("ids");9  if (ids) return json({ films: await filmsByIds(locale, ids.split(",")), nextCursor: null }, { cache: "no-store" });10  const g = (k: string) => url.searchParams.get(k)?.slice(0, 80) || undefined;11  const max = Number(g("maxDuration"));12  const page = await listFilms(locale, {13    cursor: g("cursor"), limit: Number(g("limit")) || 12, series: g("series"), tag: g("tag"), language: g("language"), kind: g("kind"),14    maxDuration: Number.isFinite(max) && max > 0 ? max : undefined, sort: g("sort") === "top" ? "top" : "latest",15  });16  return json(page);17}18
Files main
Menu

Theme