Files
CubeAdmin/app/api/server/status/route.ts
2026-03-08 17:01:36 +01:00

21 lines
697 B
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { auth, getAuthSession } from "@/lib/auth";
import { mcProcessManager } from "@/lib/minecraft/process";
import { checkRateLimit, getClientIp } from "@/lib/security/rateLimit";
export async function GET(req: NextRequest) {
const session = await getAuthSession(req.headers);
if (!session) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const ip = getClientIp(req);
const { allowed } = checkRateLimit(ip);
if (!allowed) {
return NextResponse.json({ error: "Too many requests" }, { status: 429 });
}
const status = mcProcessManager.getStatus();
return NextResponse.json(status);
}