import { NextRequest, NextResponse } from "next/server"; import { addComfyModel } from "@/lib/docker"; export const dynamic = "force-dynamic"; export const runtime = "nodejs"; /** * POST /api/comfy/models/add * Body: { url: string, type: string } * Queues a model download via model-worker. */ export async function POST(req: NextRequest) { const body = (await req.json()) as { url?: string; type?: string }; if (!body.url || !body.type) { return NextResponse.json( { ok: false, error: "url and type required" }, { status: 400 } ); } const result = await addComfyModel(body.url, body.type); return NextResponse.json( { ok: result.ok, output: result.output, error: result.error }, { status: result.ok ? 200 : 500 } ); }