Admin API and screens: dashboard and setup checklist, template and style, pages and blocks, ministries, leadership, media library with the storage limit, publish and history. Pending changes with who and when, discard one, one Publish, restore any version (each version keeps the working copy's rows, never sent to visitors). Preview on the site's own addresses with a bar (widths, back, publish); shared preview links for 7 days or until revoked. Roles checked, same-origin changes only. Publish refreshes the public pages at once (WEBSITE_CONTENT_CACHE_SECONDS). E2E on a production build: the admin's flows and axe on every screen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
18 lines
921 B
TypeScript
18 lines
921 B
TypeScript
import { revalidateTag } from "next/cache";
|
|
import { NextResponse, type NextRequest } from "next/server";
|
|
|
|
const api = (process.env.WEBSITE_API_URL || "http://127.0.0.1:5300").replace(/\/+$/, "");
|
|
|
|
/**
|
|
* Publish (WEBSITE-1.0-PLAN §1, §4) refreshes the public pages at once: the admin calls this right
|
|
* after publishing, and the next visitor gets the new version (no stale copy). Only a signed-in
|
|
* admin can ask.
|
|
*/
|
|
export async function POST(request: NextRequest) {
|
|
const session = request.cookies.get("ccw_session")?.value;
|
|
const me = session ? await fetch(`${api}/api/auth/me`, { headers: { Cookie: `ccw_session=${encodeURIComponent(session)}` }, cache: "no-store" }).catch(() => null) : null;
|
|
if (!me?.ok) return NextResponse.json({ error: { code: "SIGNED_OUT", message: "Please sign in." } }, { status: 401 });
|
|
revalidateTag("site-content", { expire: 0 });
|
|
return NextResponse.json({ ok: true });
|
|
}
|