- docker-compose: itzg/minecraft-server (Fabric, offline mode, whitelist enforced, Modrinth-managed mods), itzg/mc-backup sidecar, custom dashboard - Gated auth for offline mode: approve username -> whitelisted with a short registration window -> EasyAuth /register + /login; auto-revoke on expiry - CraftDeck panel (Next.js 16, zero native deps): live console (SSE), players & stats, lag diagnostics (server TPS vs player ping via spark), performance graphs, Modrinth mod search/manager, backups & restore, sandboxed file browser/editor, .env config editor with compose apply, cron schedules, Discord alerts, scrypt-hashed panel login - scripts/setup.sh generates secrets; docs/ covers auth, mods, updating, backups, networking (Tailscale), troubleshooting Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
22 lines
874 B
TypeScript
22 lines
874 B
TypeScript
import { NextRequest } from "next/server";
|
|
import path from "node:path";
|
|
import { writeBinaryFile } from "@/server/files";
|
|
import { ok, fail, handle } from "@/server/api";
|
|
|
|
const MAX_UPLOAD = 256 * 1024 * 1024; // mod jars and datapacks, not world dumps
|
|
|
|
export async function POST(req: NextRequest) {
|
|
return handle(async () => {
|
|
const form = await req.formData();
|
|
const dir = (form.get("dir") as string) ?? "";
|
|
const file = form.get("file");
|
|
if (!(file instanceof File)) return fail("Missing file");
|
|
if (file.size > MAX_UPLOAD) return fail("File too large (256 MB max)");
|
|
const name = path.basename(file.name);
|
|
if (!name || name.startsWith(".")) return fail("Invalid file name");
|
|
const buf = Buffer.from(await file.arrayBuffer());
|
|
writeBinaryFile(path.join(dir, name), buf);
|
|
return ok({ uploaded: name, size: file.size });
|
|
});
|
|
}
|