MCPcopy Create free account
hub / github.com/andylow92/file-system-like-github / api

Function api

apps/api/src/routes/patchFile.test.ts:34–49  ·  view source on GitHub ↗
(
    method: string,
    pathname: string,
    options: { body?: unknown; actor?: string } = {},
  )

Source from the content-addressed store, hash-verified

32 let server: http.Server | undefined;
33
34 async function api<T>(
35 method: string,
36 pathname: string,
37 options: { body?: unknown; actor?: string } = {},
38 ): Promise<{ status: number; body: ApiResponse<T> }> {
39 const headers: Record<string, string> = { 'Content-Type': 'application/json' };
40 if (options.actor) {
41 headers['X-Actor'] = options.actor;
42 }
43 const response = await fetch(`${baseUrl}${pathname}`, {
44 method,
45 headers,
46 body: options.body ? JSON.stringify(options.body) : undefined,
47 });
48 return { status: response.status, body: (await response.json()) as ApiResponse<T> };
49 }
50
51 beforeEach(async () => {
52 contentRoot = await mkdtemp(path.join(os.tmpdir(), 'patch-file-root-'));

Callers 1

patchFile.test.tsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected