40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { auth } from "@/app/(auth)/auth";
|
|
import { upscaleConfig } from "@/lib/video-canvas/video-upscale-remote";
|
|
import { NextResponse } from "next/server";
|
|
export async function GET() {
|
|
if (!(await auth())?.user?.id)
|
|
return NextResponse.json({ error: "未登录" }, { status: 401 });
|
|
try {
|
|
const config = upscaleConfig();
|
|
if (!config)
|
|
return NextResponse.json({
|
|
available: false,
|
|
message: "视频高清服务尚未接通",
|
|
});
|
|
const response = await fetch(config.base + "/health", {
|
|
headers: { authorization: "Bearer " + config.token },
|
|
signal: AbortSignal.timeout(5000),
|
|
redirect: "error",
|
|
cache: "no-store",
|
|
});
|
|
if (!response.ok) throw Error("unavailable");
|
|
const data = await response.json();
|
|
return NextResponse.json(
|
|
{
|
|
available: data.status === "ok",
|
|
engine: "Real-ESRGAN",
|
|
resolutions: ["1080P", "2K", "4K"],
|
|
maxScale: 4,
|
|
maxSeconds: 120,
|
|
queued: data.queued,
|
|
},
|
|
{ headers: { "Cache-Control": "no-store" } }
|
|
);
|
|
} catch {
|
|
return NextResponse.json(
|
|
{ available: false, message: "视频高清服务暂时不可用,请稍后重试" },
|
|
{ headers: { "Cache-Control": "no-store" } }
|
|
);
|
|
}
|
|
}
|