import { NextRequest, NextResponse } from "next/server"; import { listComfyModels } from "@/lib/docker"; export const dynamic = "force-dynamic"; export const runtime = "nodejs"; /** * GET /api/comfy/models?type= * Lists comfy models via `docker exec model-worker python3 /app/worker.py list [type]`. */ export async function GET(req: NextRequest) { const type = req.nextUrl.searchParams.get("type") || undefined; const result = await listComfyModels(type); return NextResponse.json( { ok: result.ok, models: result.models, raw: result.raw, error: result.error }, { status: result.ok ? 200 : 500 } ); }