27 lines
774 B
TypeScript
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 }),
|
|
},
|
|
});
|
|
}
|