import { NextResponse } from "next/server"; import { HOMEPAGE_TARGET } from "yt-dlp-transcript-common/publish/stamps"; import { enqueueAsks, lastJobOf, refusalsOf } from "../_publish"; import { ops, optPreviewBranch, opsFail } from "../_lib"; export const dynamic = "force-dynamic"; // AN ALIAS (release 18): the homepage's BUILT bundle, deployed — never a build. The body and the answer are the // route's old ones; the work is publish stages on the publish queue // (../_publish.ts), as `POST /api/ops/publish` {"verb": "homepage"} runs them. // // → { ok, jobId, previewUrl? }, as before; a homepage never built is refused // before any job ("no build of _homepage in — archilyzer publish homepage"). export async function POST(request: Request) { return ops(request, ["preview"], async (body) => { const preview = optPreviewBranch(body); const run = await enqueueAsks([ { target: HOMEPAGE_TARGET, deploy: { where: preview ? ("preview" as const) : ("production" as const), ...(preview ? { preview } : {}), force: true }, }, ]); const job = lastJobOf(run, HOMEPAGE_TARGET); if (!job) return opsFail(refusalsOf(run).map((r) => r.error).join("; ") || "nothing was enqueued"); return NextResponse.json({ ok: true, jobId: job.jobId, runId: run.runId, ...(job.previewUrl ? { previewUrl: job.previewUrl } : {}), }); }); } export function GET() { return NextResponse.json({ ok: false, error: "POST only" }, { status: 405 }); }