Initial 智念AIGC platform
This commit is contained in:
25
app/api/generations/video/route.ts
Normal file
25
app/api/generations/video/route.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { listGenerationJobs } from "@/lib/server/data-store";
|
||||
import { jsonError, jsonOk, readJsonBody } from "@/lib/server/api";
|
||||
import { requestOrigin } from "@/lib/server/runtime";
|
||||
import { submitVideoJob, type SubmitVideoJobInput } from "@/lib/server/video-generation-service";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const jobs = (await listGenerationJobs()).filter((job) => job.capability === "video.generate");
|
||||
return jsonOk({ jobs });
|
||||
} catch (error) {
|
||||
return jsonError(error, 500);
|
||||
}
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const body = await readJsonBody<SubmitVideoJobInput & Record<string, unknown>>(request);
|
||||
const job = await submitVideoJob(body, requestOrigin(request));
|
||||
return jsonOk({ job }, { status: 202 });
|
||||
} catch (error) {
|
||||
return jsonError(error);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user