export type GetApiV2StatusHeartbeatArgs = {'Client-Agent'?: string | undefined}; export type GetApiV2StatusHeartbeatOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * If this loads, this node is available * * GET /v2/status/heartbeat */ export const getApiV2StatusHeartbeat = async (args: GetApiV2StatusHeartbeatArgs, options: GetApiV2StatusHeartbeatOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['Client-Agent'] != null) headers.set("Client-Agent", String(args['Client-Agent'])) const url = `${baseUrl.replace(/\/+$/, '')}/v2/status/heartbeat${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };