Files
erika/app/api/admin/video-upload/route.ts
T

19 lines
652 B
TypeScript

import { NextResponse } from "next/server";
import { requireAdmin } from "@/lib/auth";
import { saveVideoUpload } from "@/lib/video-upload-storage";
export const dynamic = "force-dynamic";
export async function POST(request: Request) {
try {
const discordId = await requireAdmin();
const id = await saveVideoUpload(await request.formData(), discordId);
return NextResponse.json({ id });
} catch (error) {
const message = error instanceof Error ? error.message : "Upload failed.";
const status =
message === "Unauthorized" || message === "Not authenticated" ? 401 : 400;
return NextResponse.json({ error: message }, { status });
}
}