Initial commit

This commit is contained in:
JetSprow
2026-04-29 05:12:39 +10:00
commit 27dbca9cbf
379 changed files with 43486 additions and 0 deletions

25
src/lib/api-response.ts Normal file
View File

@@ -0,0 +1,25 @@
import { NextResponse } from "next/server";
import { getErrorMessage } from "./errors";
export function jsonError(
error: unknown,
options?: {
status?: number;
fallback?: string;
headers?: HeadersInit;
},
) {
return NextResponse.json(
{
error: getErrorMessage(error, options?.fallback ?? "请求失败"),
},
{
status: options?.status ?? 500,
headers: options?.headers,
},
);
}
export function jsonOk<T>(data: T, init?: ResponseInit) {
return NextResponse.json(data, init);
}