import { NextResponse } from "next/server"; import { indexPlan } from "../../../sites/lib/publishCore"; import { enqueuePlan, publishResponse } from "../_publish"; import { ops, optString } from "../_lib"; export const dynamic = "force-dynamic"; // AN ALIAS (release 18): the index update. 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": "index"} runs them. // // `queueKey` is accepted and ignored: the index update is a publish stage, and // the publish queue runs its stages one at a time. export async function POST(request: Request) { return ops(request, ["queueKey"], async (body) => { optString(body, "queueKey"); return publishResponse(await enqueuePlan(indexPlan())); }); } export function GET() { return NextResponse.json({ ok: false, error: "POST only" }, { status: 405 }); }