MCPcopy
hub / github.com/inkeep/open-knowledge / fetchText

Function fetchText

packages/cli/src/commands/start.test.ts:413–436  ·  view source on GitHub ↗
(
  port: number,
  path: string,
)

Source from the content-addressed store, hash-verified

411const TEST_HOST = '127.0.0.1';
412
413function fetchText(
414 port: number,
415 path: string,
416): Promise<{
417 status: number;
418 body: string;
419 headers: Record<string, string | string[] | undefined>;
420}> {
421 return new Promise((resolveFetch, reject) => {
422 const req = httpRequest({ hostname: '127.0.0.1', port, path, method: 'GET' }, (res) => {
423 let body = '';
424 res.setEncoding('utf-8');
425 res.on('data', (chunk) => {
426 body += chunk;
427 });
428 res.on('end', () => {
429 resolveFetch({ status: res.statusCode ?? 0, body, headers: res.headers });
430 });
431 res.on('error', reject);
432 });
433 req.on('error', reject);
434 req.end();
435 });
436}
437
438describe('resolveCollabPort (collab vs UI-sibling port suppression)', () => {
439 test('explicit --port always wins', () => {

Callers 1

start.test.tsFile · 0.85

Calls 2

onMethod · 0.65
endMethod · 0.65

Tested by

no test coverage detected