Aktueller Stand

This commit is contained in:
2026-01-15 23:18:42 +01:00
parent 46eae2a2a9
commit dcf45bac3d
32 changed files with 2625 additions and 395 deletions

View File

@@ -0,0 +1,39 @@
import { NextResponse } from "next/server";
import { prisma } from "../../../../lib/prisma";
import { isSuperAdminSession, requireSession } from "../../../../lib/auth-helpers";
const DEFAULT_APP_NAME = "Vereinskalender";
export async function GET() {
const setting = await prisma.setting.findUnique({
where: { key: "app_name" }
});
return NextResponse.json({ name: setting?.value || DEFAULT_APP_NAME });
}
export async function POST(request: Request) {
const { session } = await requireSession();
if (!session) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
if (!isSuperAdminSession(session)) {
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
}
const body = await request.json();
const name = String(body?.name || "").trim();
if (!name) {
return NextResponse.json({ error: "Name erforderlich." }, { status: 400 });
}
if (name.length > 60) {
return NextResponse.json({ error: "Name ist zu lang." }, { status: 400 });
}
await prisma.setting.upsert({
where: { key: "app_name" },
update: { value: name },
create: { key: "app_name", value: name }
});
return NextResponse.json({ name });
}

View File

@@ -16,6 +16,7 @@ const MIME_TO_EXT: Record<string, string> = {
"image/webp": "webp",
"image/svg+xml": "svg"
};
const MAX_FILE_SIZE = 2 * 1024 * 1024;
const resolveLogoPath = (relativePath: string) => {
const absolutePath = path.join(DATA_DIR, relativePath);
@@ -51,6 +52,9 @@ export async function POST(request: Request) {
if (!extension) {
return NextResponse.json({ error: "Dateityp nicht unterstützt." }, { status: 400 });
}
if (file.size > MAX_FILE_SIZE) {
return NextResponse.json({ error: "Datei ist zu groß (max. 2 MB)." }, { status: 400 });
}
await fs.mkdir(UPLOADS_DIR, { recursive: true });