Files
2026-09-17 21:54:33 +08:00

15 lines
684 B
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { cleanupIdleNodeModules } from "../../../../lib/cleanup";
import { errorResponse } from "../../../../lib/http";
export const runtime = "nodejs";
export async function POST(request: NextRequest) {
try {
const body = await request.json().catch(() => ({}));
const idleHours = body.idleHours === undefined ? undefined : Number(body.idleHours);
if (idleHours !== undefined && (!Number.isFinite(idleHours) || idleHours < 0)) throw new Error("idleHours must be a non-negative number");
return NextResponse.json(await cleanupIdleNodeModules(idleHours));
} catch (error) { return errorResponse(error); }
}