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

Function serveMutableSpec

e2e/cloud/spec-update-convergence.test.ts:76–106  ·  view source on GitHub ↗
(initial: string)

Source from the content-addressed store, hash-verified

74
75/** A real 127.0.0.1 server whose served spec can be swapped mid-scenario. */
76const serveMutableSpec = (initial: string) =>
77 Effect.acquireRelease(
78 Effect.callback<{
79 readonly url: string;
80 readonly setBody: (body: string) => void;
81 readonly close: () => void;
82 }>((resume) => {
83 let body = initial;
84 const server = createServer((_request, response) => {
85 response.writeHead(200, { "content-type": "application/json" });
86 response.end(body);
87 });
88 server.listen(0, "127.0.0.1", () => {
89 const address = server.address();
90 const port = typeof address === "object" && address ? address.port : 0;
91 resume(
92 Effect.succeed({
93 url: `http://127.0.0.1:${port}/spec.json`,
94 setBody: (next: string) => {
95 body = next;
96 },
97 close: () => {
98 server.close();
99 server.closeAllConnections();
100 },
101 }),
102 );
103 });
104 }),
105 (server) => Effect.sync(server.close),
106 );
107
108// ── Session plumbing over the real auth endpoints (mirrors the web app) ──────
109const cookieOf = (identity: Identity): string => identity.headers?.["cookie"] ?? "";

Callers 1

Calls 6

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

Tested by

no test coverage detected