feat: full site build — Project/Melody schema (Option A), admin CRUD, public sections, uploads, email+SMTP, internal analytics, legal pages, docs

This commit is contained in:
2026-08-05 20:53:40 +02:00
parent d87f3033c6
commit c26f41511f
122 changed files with 15068 additions and 41 deletions
+33
View File
@@ -0,0 +1,33 @@
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { saveUploadedFile, UploadError } from "@/lib/upload";
import { uploadKindSchema } from "@/lib/validations/upload";
export const runtime = "nodejs";
export async function POST(request: Request) {
const session = await auth();
if (!session?.user) {
return NextResponse.json({ error: "Unauthorized." }, { status: 401 });
}
try {
const formData = await request.formData();
const kindResult = uploadKindSchema.safeParse(formData.get("kind"));
const file = formData.get("file");
if (!kindResult.success || !(file instanceof File)) {
return NextResponse.json({ error: "A valid upload kind and file are required." }, { status: 400 });
}
const uploadedFile = await saveUploadedFile(file, kindResult.data);
return NextResponse.json(uploadedFile, { status: 201 });
} catch (error) {
if (error instanceof UploadError) {
return NextResponse.json({ error: error.message }, { status: error.statusCode });
}
console.error("Upload failed", error);
return NextResponse.json({ error: "The file could not be uploaded." }, { status: 500 });
}
}