MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / request

Function request

__tests__/ui-flow-api.test.ts:43–69  ·  view source on GitHub ↗
(requestPath: string)

Source from the content-addressed store, hash-verified

41let projectRoot: string;
42
43function request(requestPath: string): Promise<{ status: number; body: string; type?: string }> {
44 return new Promise((resolve, reject) => {
45 const req = http.request(
46 {
47 host: '127.0.0.1',
48 port: server.port,
49 path: requestPath,
50 method: 'GET',
51 headers: { Host: `127.0.0.1:${server.port}` },
52 setHost: false,
53 },
54 (res) => {
55 const chunks: Buffer[] = [];
56 res.on('data', (c: Buffer) => chunks.push(c));
57 res.on('end', () =>
58 resolve({
59 status: res.statusCode ?? 0,
60 body: Buffer.concat(chunks).toString('utf-8'),
61 type: res.headers['content-type'],
62 })
63 );
64 }
65 );
66 req.on('error', reject);
67 req.end();
68 });
69}
70
71async function getFlow(query: string, expected = 200): Promise<any> {
72 const res = await request(`/api/flow${query}`);

Callers 2

getFlowFunction · 0.70

Calls 4

pushMethod · 0.80
resolveFunction · 0.70
requestMethod · 0.65
onMethod · 0.65

Tested by

no test coverage detected