import { NextRequest, NextResponse } from "next/server"; import { sleepMode, wakeMode, updateNode } from "@/lib/docker"; export const dynamic = "force-dynamic"; export const runtime = "nodejs"; export const maxDuration = 600; /** * POST /api/system * Body: { action: "sleep" | "wake" | "update" } * * Mirrors `gpuctl sleep|wake|update` CLI commands. */ export async function POST(req: NextRequest) { const body = (await req.json()) as { action: "sleep" | "wake" | "update" }; if (body.action === "sleep") { const result = await sleepMode(); return NextResponse.json(result, { status: result.ok ? 200 : 500 }); } if (body.action === "wake") { const result = await wakeMode(); return NextResponse.json(result, { status: result.ok ? 200 : 500 }); } if (body.action === "update") { const result = await updateNode(); return NextResponse.json(result, { status: result.ok ? 200 : 500 }); } return NextResponse.json({ error: "unknown action" }, { status: 400 }); }