import { NextResponse } from "next/server"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { NetworkInputError, assignChannelExit } from "yt-dlp-transcript-common/controller/networkExits"; import { OpsInputError, ops, reqSlug, reqString } from "../_lib"; export const dynamic = "force-dynamic"; // POST { slug, exit } // // THE OPERATOR'S REASSIGNMENT of a channel's network exit (lane // network-exits): the only way a channel's sticky exit changes besides its // exit being removed or disabled. `exit` is one of the platform's enabled // exits or "direct". Answers { ok, slug, platform, exit, previous }. Refused // for a channel whose platform has no network policy. export async function POST(request: Request) { return ops(request, ["slug", "exit"], async (body) => { try { const r = await assignChannelExit({ paths: getPaths(), slug: reqSlug(body, "slug"), exit: reqString(body, "exit") }); return NextResponse.json({ ok: true, ...r }); } catch (e) { if (e instanceof NetworkInputError) throw new OpsInputError(e.message); throw e; } }); }