import { NextResponse } from "next/server"; import { z } from "zod"; import { withAuth } from "@/lib/api-auth"; import { apiError, handleApiError } from "@/lib/api-errors"; import { getBackdrop, saveBackdrop, SettingsError } from "@/lib/settings"; export const dynamic = "force-dynamic"; /** Appearance: the custom picture behind the page headers (null for the built-in painting). */ export const GET = withAuth(async () => NextResponse.json({ backdrop: await getBackdrop() })); const Body = z.object({ backdrop: z.unknown() }); export const PUT = withAuth(async (req) => { try { const body = Body.parse(await req.json()); return NextResponse.json({ backdrop: await saveBackdrop(body.backdrop ?? null) }); } catch (err) { if (err instanceof SettingsError) return apiError(err.status, err.code, err.message); return handleApiError(err); } });