store only status-change events; UI client-side polling refactor
This commit is contained in:
19
web/src/app/api/poll/incidents/route.ts
Normal file
19
web/src/app/api/poll/incidents/route.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import { loadIncidents } from "@/lib/loaders";
|
||||
import { jsonError } from "@/lib/poll-response";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const url = new URL(request.url);
|
||||
const stateParam = url.searchParams.get("state");
|
||||
const state = stateParam === "open" || stateParam === "resolved" ? stateParam : undefined;
|
||||
|
||||
try {
|
||||
const data = await loadIncidents(state);
|
||||
return NextResponse.json(data);
|
||||
} catch (e) {
|
||||
return jsonError(e);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user