Initial 智念AIGC platform

This commit is contained in:
inman
2026-05-29 10:26:02 +08:00
commit f9c3393f84
86 changed files with 14741 additions and 0 deletions

19
lib/server/api.ts Normal file
View File

@@ -0,0 +1,19 @@
import { NextResponse } from "next/server";
export function jsonOk<T>(payload: T, init?: ResponseInit) {
return NextResponse.json(payload, init);
}
export function jsonError(error: unknown, status = 400) {
return NextResponse.json({
error: error instanceof Error ? error.message : String(error)
}, { status });
}
export async function readJsonBody<T extends Record<string, unknown>>(request: Request): Promise<T> {
try {
return await request.json() as T;
} catch {
return {} as T;
}
}