Skip to content

One-click character swap for videos: an open-source, local Higgsfield Genjutsu alternative built on ComfyUI and MiniMax H3, with FLUX.3 Klein relighting.

1.1 KB
Raw Blame
import { apiAccess, HttpError } from "../../../../lib/http.ts";
import { NextResponse } from "next/server";
import { getJob, publicJob } from "../../../../lib/comfy.ts";

export const runtime = "nodejs";

export async function GET(request: Request, { params }: { params: Promise<{ id: string }> }) {
  const denied = apiAccess(request);
  if (denied) return denied;
  try {
    const { id } = await params;
    return NextResponse.json(publicJob(await getJob(id)));
  } catch (error) {
    return NextResponse.json({ error: error instanceof Error ? error.message : "Unable to check the job." }, { status: error instanceof HttpError ? error.status : 502 });
  }
}

export async function DELETE(request: Request, { params }: { params: Promise<{ id: string }> }) {
  const denied = apiAccess(request);
  if (denied) return denied;
  try {
    const { id } = await params;
    const job = await getJob(id);
    return NextResponse.json(publicJob(await job.cancel()));
  } catch (error) {
    return NextResponse.json({ error: error instanceof Error ? error.message : "Unable to cancel the job." }, { status: error instanceof HttpError ? error.status : 502 });
  }
}