MCPcopy
hub / github.com/garrytan/gstack / api

Function api

browse/test/sidebar-integration.test.ts:20–30  ·  view source on GitHub ↗
(pathname: string, opts: RequestInit & { noAuth?: boolean } = {})

Source from the content-addressed store, hash-verified

18let queueFile: string = '';
19
20async function api(pathname: string, opts: RequestInit & { noAuth?: boolean } = {}): Promise<Response> {
21 const { noAuth, ...fetchOpts } = opts;
22 const headers: Record<string, string> = {
23 'Content-Type': 'application/json',
24 ...(fetchOpts.headers as Record<string, string> || {}),
25 };
26 if (!noAuth && !headers['Authorization'] && authToken) {
27 headers['Authorization'] = `Bearer ${authToken}`;
28 }
29 return fetch(`http://127.0.0.1:${serverPort}${pathname}`, { ...fetchOpts, headers });
30}
31
32beforeAll(async () => {
33 tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'sidebar-integ-'));

Callers 2

resetStateFunction · 0.70

Calls 1

fetchFunction · 0.70

Tested by

no test coverage detected