Initial open-source self-hosted Songs2YT edition

This commit is contained in:
Songs2YT
2026-07-17 02:23:59 +02:00
commit 2aa8a84781
134 changed files with 17758 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import { NextRequest, NextResponse } from "next/server";
import { saveUploadedFile } from "@/lib/jobs/create-job";
import { getSessionUser } from "@/lib/session";
export const maxDuration = 120;
export async function POST(req: NextRequest) {
const user = await getSessionUser();
if (!user) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const formData = await req.formData();
const file = formData.get("file") as File | null;
const type = formData.get("type") as string | null;
const sessionKey = (formData.get("session") as string | null)?.trim() || undefined;
if (!file || !type || (type !== "image" && type !== "audio")) {
return NextResponse.json({ error: "Missing file or type" }, { status: 400 });
}
try {
const result = await saveUploadedFile(user.id, file, type, user.plan, { sessionKey });
return NextResponse.json(result);
} catch (err) {
const message = err instanceof Error ? err.message : "Upload failed";
return NextResponse.json({ error: message }, { status: 400 });
}
}