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

Function postJson

e2e/cloud/spec-update-convergence.test.ts:112–130  ·  view source on GitHub ↗
(target: TargetShape, path: string, identity: Identity, body: unknown)

Source from the content-addressed store, hash-verified

110const ORG_SELECTOR_HEADER = "x-executor-organization";
111
112const postJson = (target: TargetShape, path: string, identity: Identity, body: unknown) =>
113 Effect.promise(async () => {
114 const response = await fetch(new URL(path, target.baseUrl), {
115 method: "POST",
116 headers: {
117 // The identity's own headers (session cookie + org selector) exactly
118 // as its API client would send them — org-scoped endpoints fail
119 // closed without the selector.
120 ...(identity.headers ?? {}),
121 "content-type": "application/json",
122 origin: new URL(target.baseUrl).origin,
123 },
124 body: JSON.stringify(body),
125 });
126 if (!response.ok) {
127 throw new Error(`${path} failed (${response.status}): ${await response.text()}`);
128 }
129 return response;
130 });
131
132const withRefreshedSession = (
133 identity: Identity,

Callers 1

joinOrgFunction · 0.70

Calls 2

textMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected