Files
Kaname/src/app/api/settings/appearance/route.ts
T
Pascal LinxweilerandClaude Opus 5.5 02756ddf90 Custom background picture for the dot matrix headers
Settings → Appearance: upload an image and every page header draws it as
the dot matrix instead of The Creation of Adam, with a clickable focus
point and a switch back to the built-in painting. The browser turns the
image into a brightness grid; only that grid is saved as a setting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 20:13:48 +01:00

23 lines
868 B
TypeScript

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);
}
});