import { NextResponse } from "next/server"; import { deleteChannelFromForm } from "../../../channels/actions"; import { opsFail, ops, reqSlug, reqString } from "../_lib"; export const dynamic = "force-dynamic"; // POST { slug: string, confirm: string } // // The channel page's Danger → Delete, over HTTP: the whole channel directory // — every transcript, sidecar, post and media link — goes. `confirm` is the // form's "type the slug" box and must equal `slug` exactly; the action is what // compares them, and refuses in the form's own sentence. Every other refusal is // the form's too: a busy channel, media in transition. // // There is no undo, and transcripts/ is its own git repo — the only way back // is a commit there. export async function POST(request: Request) { return ops(request, ["slug", "confirm"], async (body) => { const slug = reqSlug(body, "slug"); const fd = new FormData(); fd.set("confirmSlug", reqString(body, "confirm")); const result = await deleteChannelFromForm(slug, fd); if (!result.ok) return opsFail(result.error); return NextResponse.json({ ok: true, slug: result.slug, deleted: true }); }); }