Files
kandev/apps/web/lib/api/domains/runtime-flags-api.ts
T
2026-06-15 13:33:45 +01:00

27 lines
774 B
TypeScript

import { fetchJson, type ApiRequestOptions } from "../client";
import type { RuntimeFlagsResponse } from "@/lib/types/runtime-flags";
const RUNTIME_FLAGS_BASE = "/api/v1/runtime-flags";
export function fetchRuntimeFlags(options?: ApiRequestOptions): Promise<RuntimeFlagsResponse> {
return fetchJson<RuntimeFlagsResponse>(RUNTIME_FLAGS_BASE, {
...options,
cache: "no-store",
});
}
export function updateRuntimeFlag(
key: string,
override: boolean | null,
options?: ApiRequestOptions,
): Promise<RuntimeFlagsResponse> {
return fetchJson<RuntimeFlagsResponse>(`${RUNTIME_FLAGS_BASE}/${encodeURIComponent(key)}`, {
...options,
init: {
...(options?.init ?? {}),
method: "PATCH",
body: JSON.stringify({ override }),
},
});
}