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/files/document/route.ts
968 B
import { NextResponse } from "next/server";
import { deleteDocument, FileOpError } from "@/lib/files/manager";

/**
 * Delete a single managed document.
 *
 *   DELETE /api/files/document   { path }
 */

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

export async function DELETE(request: Request) {
  let body: { path?: string };
  try {
    body = await request.json();
  } catch {
    return NextResponse.json({ error: "Invalid JSON." }, { status: 400 });
  }
  if (!body.path) {
    return NextResponse.json({ error: "A path is required." }, { status: 400 });
  }
  try {
    deleteDocument(body.path);
    return NextResponse.json({ ok: true });
  } catch (err) {
    if (err instanceof FileOpError) {
      return NextResponse.json({ error: err.message }, { status: err.status });
    }
    const message = err instanceof Error ? err.message : "Delete failed.";
    return NextResponse.json({ error: message }, { status: 500 });
  }
}

root · /srv/aaf