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

Function serveMutableSpec

e2e/scenarios/openapi-update-spec.test.ts:70–100  ·  view source on GitHub ↗
(initial: string)

Source from the content-addressed store, hash-verified

68
69/** A real 127.0.0.1 server whose served spec can be swapped mid-scenario. */
70const serveMutableSpec = (initial: string) =>
71 Effect.acquireRelease(
72 Effect.callback<{
73 readonly url: string;
74 readonly setBody: (body: string) => void;
75 readonly close: () => void;
76 }>((resume) => {
77 let body = initial;
78 const server = createServer((_request, response) => {
79 response.writeHead(200, { "content-type": "application/json" });
80 response.end(body);
81 });
82 server.listen(0, "127.0.0.1", () => {
83 const address = server.address();
84 const port = typeof address === "object" && address ? address.port : 0;
85 resume(
86 Effect.succeed({
87 url: `http://127.0.0.1:${port}/spec.json`,
88 setBody: (next: string) => {
89 body = next;
90 },
91 close: () => {
92 server.close();
93 server.closeAllConnections();
94 },
95 }),
96 );
97 });
98 }),
99 (server) => Effect.sync(server.close),
100 );
101
102const updateSpecCode = (slug: string) => `
103const updated = await tools.executor.openapi.updateSpec({

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