MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / serveCaptureUpstream

Function serveCaptureUpstream

e2e/cloud/connections-credentials.test.ts:49–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47 * `GET /ping`. This is how a scenario proves WHICH stored secret a connection
48 * resolves, since no endpoint ever echoes the value itself. */
49const serveCaptureUpstream = () =>
50 Effect.acquireRelease(
51 Effect.callback<CaptureUpstream>((resume) => {
52 const headers: string[] = [];
53 const server = createServer((request, response) => {
54 if (request.method === "GET" && (request.url ?? "").startsWith("/ping")) {
55 headers.push(request.headers.authorization ?? "");
56 response.writeHead(200, { "content-type": "application/json" });
57 response.end(JSON.stringify({ pong: true }));
58 return;
59 }
60 response.writeHead(404, { "content-type": "application/json" });
61 response.end(JSON.stringify({ error: "not_found" }));
62 });
63 server.listen(0, "127.0.0.1", () => {
64 const address = server.address();
65 const port = typeof address === "object" && address ? address.port : 0;
66 resume(
67 Effect.succeed({
68 url: `http://127.0.0.1:${port}`,
69 authorizationHeaders: () => [...headers],
70 close: () => {
71 server.close();
72 server.closeAllConnections();
73 },
74 }),
75 );
76 });
77 }),
78 (upstream) => Effect.sync(upstream.close),
79 );
80
81/** Registers a fresh apiKey-authenticated integration for connections to bind
82 * to. Identifier-safe slug: it becomes a property path in sandbox code. */

Callers 1

Calls 7

resumeFunction · 0.85
pushMethod · 0.80
endMethod · 0.80
listenMethod · 0.80
addressMethod · 0.80
closeMethod · 0.65
syncMethod · 0.65

Tested by

no test coverage detected