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

Function serveMutableSpec

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

Source from the content-addressed store, hash-verified

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

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