Minecraft 26.2 Fabric server stack with CraftDeck management panel
- 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>
This commit is contained in:
commit
279d137ce5
98 files changed
+9925
No files matched your search
@@ -0,0 +1,49 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { DockerError } from "./docker";
|
||||
import { RconError } from "./rcon";
|
||||
|
||||
/**
|
||||
* Small helpers for route handlers. Authentication is enforced globally in
|
||||
* middleware.ts; these standardize success/error payloads and translate
|
||||
* infrastructure failures into friendly 503s.
|
||||
*/
|
||||
|
||||
export function ok(data: unknown, init?: ResponseInit): NextResponse {
|
||||
return NextResponse.json({ ok: true, data }, init);
|
||||
}
|
||||
|
||||
export function fail(message: string, status = 400): NextResponse {
|
||||
return NextResponse.json({ ok: false, error: message }, { status });
|
||||
}
|
||||
|
||||
export function handle(fn: () => Promise<NextResponse> | NextResponse) {
|
||||
return (async () => {
|
||||
try {
|
||||
return await fn();
|
||||
} catch (err) {
|
||||
if (err instanceof DockerError && err.kind === "unavailable") {
|
||||
return fail("Docker is unreachable from the panel", 503);
|
||||
}
|
||||
if (err instanceof DockerError && err.kind === "not_found") {
|
||||
return fail("Container not found — is the stack deployed?", 503);
|
||||
}
|
||||
if (err instanceof RconError) {
|
||||
return fail(
|
||||
err.kind === "auth"
|
||||
? "RCON authentication failed — check RCON_PASSWORD"
|
||||
: "Server console unreachable (is the server running?)",
|
||||
503
|
||||
);
|
||||
}
|
||||
return fail((err as Error).message || "Internal error", 500);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
export async function readJson<T>(req: Request): Promise<T> {
|
||||
try {
|
||||
return (await req.json()) as T;
|
||||
} catch {
|
||||
throw new Error("Invalid JSON body");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user