MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / requestLighthouse

Function requestLighthouse

packages/web/src/features/billing/client.ts:31–47  ·  view source on GitHub ↗
(
    path: string,
    init: RequestInit,
    schema: T,
    retryOptions: { retries?: number; backoffMs?: number } = {},
)

Source from the content-addressed store, hash-verified

29import { z } from "zod";
30
31const requestLighthouse = async <T extends z.ZodTypeAny>(
32 path: string,
33 init: RequestInit,
34 schema: T,
35 retryOptions: { retries?: number; backoffMs?: number } = {},
36): Promise<z.infer<T> | ServiceError> => {
37 const url = `${env.SOURCEBOT_LIGHTHOUSE_URL}${path}`;
38
39 let response: Response;
40 try {
41 response = await fetchWithRetry(url, init, retryOptions)
42 } catch (error) {
43 return lighthouseUnreachable(url, error);
44 }
45
46 return parseResponseBody(response, schema);
47}
48
49const jsonPost = (body: unknown): RequestInit => ({
50 method: 'POST',

Callers 1

client.tsFile · 0.85

Calls 3

fetchWithRetryFunction · 0.90
lighthouseUnreachableFunction · 0.90
parseResponseBodyFunction · 0.85

Tested by

no test coverage detected