Initial commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { assertLocalRequest } from "@/lib/api/localOnly";
|
||||
import { verifyCli, autoDetectCli } from "@/lib/whisperjav/spawn";
|
||||
import { getAppSetting } from "@/lib/db/appSettings";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
const blocked = assertLocalRequest(req);
|
||||
if (blocked) return blocked;
|
||||
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const explicit = typeof body.path === "string" ? body.path.trim() : "";
|
||||
const autodetect = body.autodetect === true;
|
||||
|
||||
let cliPath = explicit;
|
||||
if (!cliPath && !autodetect) {
|
||||
cliPath = (getAppSetting("whisperjav").cliPath ?? "").trim();
|
||||
}
|
||||
if (!cliPath) {
|
||||
const detected = await autoDetectCli();
|
||||
if (!detected) {
|
||||
return NextResponse.json({ ok: false, error: "whisperjav not found on PATH" });
|
||||
}
|
||||
cliPath = detected;
|
||||
}
|
||||
|
||||
const result = await verifyCli(cliPath);
|
||||
return NextResponse.json(result);
|
||||
}
|
||||
Reference in New Issue
Block a user