MCPcopy
hub / github.com/coder/mux / createApiClient

Function createApiClient

vscode/src/api/client.ts:28–52  ·  view source on GitHub ↗
(config: ApiClientConfig)

Source from the content-addressed store, hash-verified

26}
27
28export function createApiClient(config: ApiClientConfig): ApiClient {
29 assert(typeof config.baseUrl === "string", "baseUrl must be a string");
30
31 const normalizedBaseUrl = normalizeBaseUrl(config.baseUrl);
32
33 const link = new RPCLink({
34 url: `${normalizedBaseUrl}/orpc`,
35 async fetch(request, init) {
36 const headers = new Headers(request.headers);
37 if (config.authToken) {
38 headers.set("Authorization", `Bearer ${config.authToken}`);
39 }
40
41 return fetch(request.url, {
42 body: await request.blob(),
43 headers,
44 method: request.method,
45 signal: request.signal,
46 ...init,
47 });
48 },
49 });
50
51 return createClient(link);
52}

Callers 3

tryGetApiClientFunction · 0.90
debugConnectionCommandFunction · 0.90

Calls 3

createClientFunction · 0.90
normalizeBaseUrlFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected