File size: 485 Bytes
7f88bdf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import { NextResponse } from "next/server";
import type { ApiResponse } from "@tenderhub/schemas";
export function ok<T>(data: T, status = 200) {
const body: ApiResponse<T> = { ok: true, data };
return NextResponse.json(body, { status });
}
export const success = ok;
export function fail(message: string, status = 400, details?: unknown) {
const body: ApiResponse<never> = {
ok: false,
error: { message, details }
};
return NextResponse.json(body, { status });
}
|