21 lines
697 B
TypeScript
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);
|
|
}
|