Skip to content
Source
Sign inSign up
samwillis/hackernews-realtime
Open History to see the last commit

route.ts

21 lines569 Bytes

1import { eventQuery, sealEvents } from "@/lib/queries";
2export const dynamic = "force-dynamic";
3export async function GET(request: Request) {
4 try {
5 const [events, query] = await Promise.all([
6 new URL(request.url).searchParams.has("capability")
7 ? Promise.resolve([])
8 : eventQuery(),
9 sealEvents(),
10 ]);
11 return Response.json(
12 { events, query },
13 { headers: { "Cache-Control": "no-store" } },
14 );
15 } catch {
16 return Response.json(
17 { error: "Unable to load live events" },
18 { status: 503 },
19 );
20 }