import { errorResponse } from "@/lib/articles/generation"; import { readArticleProposals, reviewArticleProposal } from "@/lib/articles/verdicts"; export const dynamic = "force-dynamic"; // VERDICT PROPOSALS (release 29 M8): an article's waiting proposals, and the // operator's approve or reject of one — through the editor's verdict-review // (approve sets the claim's verdict through the registry). // // GET ?article= -> { waiting, approved, rejected } // POST {article, claim, decision: "approve" | "reject", note?} -> { proposal } export async function GET(request: Request) { const article = new URL(request.url).searchParams.get("article") ?? ""; const got = await readArticleProposals(article).catch(() => null); return Response.json(got ?? { waiting: [], approved: 0, rejected: 0 }, { headers: { "cache-control": "no-store" } }); } export async function POST(request: Request) { try { const body = await request.json().catch(() => null); return Response.json(await reviewArticleProposal(body), { headers: { "cache-control": "no-store" } }); } catch (err) { return errorResponse(err); } }