Intelligence

Artifacts

Browse the repository, read documents, and manage the governance folders. Source, runtime, and infrastructure are read-only.

Repository
globals.csslayout.tsxnot-found.tsxpage.tsx
.gitignoreDockerfilenext-env.d.tsnext.config.mjspackage-lock.jsonpackage.jsonpostcss.config.mjsREADME.mdtailwind.config.tstsconfig.jsontsconfig.tsbuildinfo
README.md
CONSTITUTION_COMPLIANCE_AUDIT_V1.mdREADME.md
repositories/aaf-holdings/hq01/app/api/missions/route.ts
1.1 KB
import { NextResponse } from "next/server";
import { createMission, listMissions, MissionError } from "@/lib/missions/manager";
import type { CreateMissionInput } from "@/lib/missions/types";

/**
 * The Mission Registry collection.
 *
 *   GET  /api/missions   → all missions
 *   POST /api/missions   → create a mission (status defaults to Planning)
 */

export const runtime = "nodejs";
export const dynamic = "force-dynamic";

export async function GET() {
  return NextResponse.json({ missions: listMissions() });
}

export async function POST(request: Request) {
  let body: CreateMissionInput;
  try {
    body = (await request.json()) as CreateMissionInput;
  } catch {
    return NextResponse.json({ error: "Invalid JSON." }, { status: 400 });
  }
  try {
    const mission = createMission(body);
    return NextResponse.json({ mission }, { status: 201 });
  } catch (err) {
    if (err instanceof MissionError) {
      return NextResponse.json({ error: err.message }, { status: err.status });
    }
    const message = err instanceof Error ? err.message : "Could not create mission.";
    return NextResponse.json({ error: message }, { status: 500 });
  }
}

root · /srv/aaf