33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import { NextResponse } from "next/server"
|
|
import { readJournalTail } from "@/app/lib/fleet/fleetSource"
|
|
|
|
export const dynamic = "force-dynamic"
|
|
|
|
/**
|
|
* GET /api/fleet/escalations — HITL-/Escalation-Historie (Kernfeature 4):
|
|
* Journal-Filter auf type=escalation + rejected-Events (Quarantine).
|
|
* Kein psql — Escalations sind Spool-Envelopes, die DB bleibt reiner Index.
|
|
*/
|
|
export async function GET() {
|
|
try {
|
|
const tail = readJournalTail(500)
|
|
const escalations = tail.filter(
|
|
(l) => l.event === "accepted" && l.type === "escalation"
|
|
)
|
|
const rejected = tail.filter((l) => l.event === "rejected")
|
|
return NextResponse.json(
|
|
{
|
|
escalations: escalations.reverse(),
|
|
rejected: rejected.reverse(),
|
|
counts: { escalations: escalations.length, rejected: rejected.length },
|
|
},
|
|
{ headers: { "Cache-Control": "no-store" } }
|
|
)
|
|
} catch (err) {
|
|
return NextResponse.json(
|
|
{ error: `FLEET_ESCALATIONS_FAILED: ${err instanceof Error ? err.message : String(err)}` },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
}
|