import { NextResponse } from "next/server"; import { currentTemplate } from "@/lib/i18n/template"; import { ForbiddenError, requireRole, UnauthorizedError } from "@/lib/auth/session"; import { isSameOrigin } from "@/lib/origin"; // Deutsche Vorlage (alle aktuellen Übersetzungsschlüssel + Text) zum // Download – wird von einem Übersetzer ausgefüllt und anschließend // über POST /api/admin/languages/[code]/import wieder hochgeladen. export async function GET(request: Request) { try { if (!isSameOrigin(request)) throw new ForbiddenError(); await requireRole(["admin"]); } catch (err) { if (err instanceof UnauthorizedError || err instanceof ForbiddenError) { return NextResponse.json({ error: "Nicht berechtigt." }, { status: 403 }); } throw err; } const template = currentTemplate(); return new NextResponse(JSON.stringify(template, null, 2), { headers: { "Content-Type": "application/json; charset=utf-8", "Content-Disposition": 'attachment; filename="sprachvorlage.json"', }, }); }