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/executives/proposals/route.ts
1.4 KB
import { NextResponse } from "next/server";
import { createProposal, listProposals } from "@/lib/executives/proposals";

/**
 * Executive office proposals.
 *
 *   GET  /api/executives/proposals  → all proposals
 *   POST /api/executives/proposals  { proposedExecutiveId, reason, originatingInstruction }
 *
 * Creating a proposal NEVER creates the office — it is pending approval.
 */

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

export async function GET() {
  return NextResponse.json({ proposals: listProposals() });
}

export async function POST(request: Request) {
  let body: {
    proposedExecutiveId?: string;
    reason?: string;
    originatingInstruction?: string;
  };
  try {
    body = await request.json();
  } catch {
    return NextResponse.json({ error: "Invalid JSON." }, { status: 400 });
  }
  if (!body.proposedExecutiveId) {
    return NextResponse.json(
      { error: "proposedExecutiveId is required." },
      { status: 400 },
    );
  }
  try {
    const proposal = createProposal({
      proposedExecutiveId: body.proposedExecutiveId,
      reason: body.reason ?? "Routing required an unstaffed office.",
      originatingInstruction: body.originatingInstruction ?? "",
    });
    return NextResponse.json({ proposal }, { status: 201 });
  } catch (err) {
    const message = err instanceof Error ? err.message : "Could not create proposal.";
    return NextResponse.json({ error: message }, { status: 400 });
  }
}

root · /srv/aaf