emrgilhzp: Proxy the home feed with cursor paging

This commit is contained in:
2026-10-19 13:58:49 -06:00
parent 4d52e52ccf
commit 20af24b25d
4 changed files with 223 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
import { NextResponse, type NextRequest } from "next/server";
import { SESSION_COOKIE } from "@/lib/cookie";
import { clampLimit, getHomeFeedPage } from "@/lib/feed";
// GET /api/feed?cursor=<nextCursor>&limit=<n>
// Same-origin proxy for the Minnect home feed. Returns { items, nextCursor }.
// 401 { error: "sign_in" } when the session is missing or dead.
export const runtime = "nodejs";
export async function GET(req: NextRequest) {
const sessionId = req.cookies.get(SESSION_COOKIE)?.value;
const cursor = req.nextUrl.searchParams.get("cursor") || null;
const limit = clampLimit(req.nextUrl.searchParams.get("limit"));
const result = await getHomeFeedPage(sessionId, cursor, limit);
if (!result.ok) {
return NextResponse.json({ error: result.error }, { status: result.status });
}
return NextResponse.json({ items: result.items, nextCursor: result.nextCursor });
}