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]/dependencies/route.ts
1.1 KB
import { NextResponse } from "next/server";
import {
createDependency,
listDependenciesWithHistory,
GovernanceError,
} from "@/lib/missions/governance";
import type { CreateDependencyInput } from "@/lib/missions/governance";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export async function GET(_r: Request, { params }: { params: { id: string } }) {
return NextResponse.json({ dependencies: listDependenciesWithHistory(params.id) });
}
export async function POST(request: Request, { params }: { params: { id: string } }) {
let body: CreateDependencyInput;
try {
body = (await request.json()) as CreateDependencyInput;
} catch {
return NextResponse.json({ error: "Invalid JSON." }, { status: 400 });
}
try {
return NextResponse.json(
{ dependency: createDependency(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 dependency." }, { status: 500 });
}
}
root · /srv/aaf