| 1 | import { NextResponse, type NextRequest } from "next/server"; |
| 2 | import { parsePaging, type ItemList } from "@/lib/db"; |
| 3 | import { getMeetings, type Meeting } from "@/lib/feed"; |
| 4 | |
| 5 | export const dynamic = "force-dynamic"; |
| 6 | |
| 7 | |
| 8 | export async function GET(req: NextRequest) { |
| 9 | const sp = req.nextUrl.searchParams; |
| 10 | const { limit, offset } = parsePaging(sp); |
| 11 | const items = getMeetings({ |
| 12 | from: sp.get("from") || undefined, |
| 13 | to: sp.get("to") || undefined, |
| 14 | chamber: sp.get("chamber") || undefined, |
| 15 | committee: sp.get("committee") || undefined, |
| 16 | type: sp.get("type") || undefined, |
| 17 | }); |
| 18 | const total = items.length; |
| 19 | const paged = items.slice(offset, offset + limit); |
| 20 | const body: ItemList<Meeting> = { items: paged, total, limit, offset }; |
| 21 | return NextResponse.json(body); |
| 22 | } |