- 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>
20 lines
815 B
TypeScript
20 lines
815 B
TypeScript
import { NextRequest } from "next/server";
|
|
import { rcon, stripColors } from "@/server/rcon";
|
|
import { logActivity } from "@/server/db";
|
|
import { pushLogLine } from "@/server/bus";
|
|
import { ok, fail, readJson, handle } from "@/server/api";
|
|
|
|
export async function POST(req: NextRequest) {
|
|
return handle(async () => {
|
|
const { command } = await readJson<{ command?: string }>(req);
|
|
if (!command?.trim()) return fail("Empty command");
|
|
const cmd = command.trim().replace(/^\//, "");
|
|
const output = stripColors(await rcon().exec(cmd));
|
|
logActivity("console", null, cmd);
|
|
// Echo the exchange into the live console stream so it reads like a terminal.
|
|
pushLogLine(`> ${cmd}`);
|
|
if (output.trim()) for (const line of output.split("\n")) pushLogLine(line);
|
|
return ok({ output });
|
|
});
|
|
}
|