Intelligence
Artifacts
Browse the repository, read documents, and manage the governance folders. Source, runtime, and infrastructure are read-only.
Repository
repositories/aaf-holdings/hq01/app/api/missions/[id]/decisions/route.ts
1.1 KB
import { NextResponse } from "next/server";
import {
createDecision,
listDecisionsWithHistory,
GovernanceError,
} from "@/lib/missions/governance";
import type { CreateDecisionInput } from "@/lib/missions/governance";
/** Decisions are immutable — there is no PATCH; corrections create new decisions. */
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export async function GET(_r: Request, { params }: { params: { id: string } }) {
return NextResponse.json({ decisions: listDecisionsWithHistory(params.id) });
}
export async function POST(request: Request, { params }: { params: { id: string } }) {
let body: CreateDecisionInput;
try {
body = (await request.json()) as CreateDecisionInput;
} catch {
return NextResponse.json({ error: "Invalid JSON." }, { status: 400 });
}
try {
return NextResponse.json({ decision: createDecision(params.id, body) }, { status: 201 });
} catch (err) {
if (err instanceof GovernanceError)
return NextResponse.json({ error: err.message }, { status: err.status });
return NextResponse.json({ error: "Could not create decision." }, { status: 500 });
}
}
root · /srv/aaf