This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
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); }
|
||||
}
|
||||
Reference in New Issue
Block a user