v2.0: sound library, image upload, DnD, ResourceBrowser, Barotrauma HUD, captain sanity
Deploy / build-and-deploy (push) Failing after 52s

This commit is contained in:
2026-06-15 01:07:05 +03:00
parent 9deec9d23e
commit d0cd008f6e
16 changed files with 1039 additions and 231 deletions
+15
View File
@@ -1,5 +1,7 @@
import { NextRequest, NextResponse } from "next/server";
import { getServerSession } from "@/lib/auth";
import { db } from "@/lib/db";
import { sounds } from "@/lib/db/schema";
import { writeFile, mkdir } from "fs/promises";
import path from "path";
import { v4 as uuidv4 } from "uuid";
@@ -32,6 +34,19 @@ export async function POST(req: NextRequest) {
const bytes = await file.arrayBuffer();
await writeFile(filepath, Buffer.from(bytes));
// approximate duration
const duration = Math.round((file.size / (64 * 128)) * 10) / 10;
const id = uuidv4();
db.insert(sounds).values({
id,
originalName: file.name,
storedFilename: filename,
duration: Math.min(duration, 6),
uploadedBy: session.id,
createdAt: new Date().toISOString(),
}).run();
return NextResponse.json({ url: `/uploads/sounds/${filename}` });
} catch {
return NextResponse.json({ error: "Upload failed" }, { status: 500 });