import { NextResponse } from "next/server"; import { withAuth } from "@/lib/api-auth"; import { getScanState, requestFolderScan } from "@/lib/local-folders"; export const dynamic = "force-dynamic"; /** Ask the worker to rescan the models folder (importable folders, and local models' files). */ export const POST = withAuth(async () => { const requestedAt = await requestFolderScan(); return NextResponse.json({ requestedAt: requestedAt.getTime() }, { status: 202 }); }); /** When the worker last finished a scan, so a client can wait for the one it asked for. */ export const GET = withAuth(async () => { return NextResponse.json(await getScanState()); });