feat(api): complete phase 9 mobile contracts

This commit is contained in:
poyrazavsever
2026-07-17 09:38:22 +03:00
parent 46a746d2d4
commit b04031a3e3
25 changed files with 4896 additions and 19 deletions
+24
View File
@@ -0,0 +1,24 @@
import "server-only";
import type { NextResponse } from "next/server";
import { apiError, apiSuccess } from "../responses";
import { NETA_API_VERSION } from "./contracts";
export function apiV1Success<T>(
data: T,
init?: ResponseInit,
): NextResponse {
return withV1Headers(apiSuccess(data, init));
}
export function apiV1Error(error: unknown): NextResponse {
return withV1Headers(apiError(error));
}
function withV1Headers(response: NextResponse): NextResponse {
response.headers.set("X-Neta-API-Version", NETA_API_VERSION);
if (!response.headers.has("Cache-Control")) {
response.headers.set("Cache-Control", "private, no-store");
}
return response;
}