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

Function postJson

e2e/cloud/connection-owner-isolation.test.ts:69–87  ·  view source on GitHub ↗
(target: TargetShape, path: string, identity: Identity, body: unknown)

Source from the content-addressed store, hash-verified

67// responses re-seal the session when the active org changes.
68
69const postJson = (target: TargetShape, path: string, identity: Identity, body: unknown) =>
70 Effect.promise(async () => {
71 const response = await fetch(new URL(path, target.baseUrl), {
72 method: "POST",
73 headers: {
74 // The identity's own headers (session cookie + org selector) exactly
75 // as its API client would send them — org-scoped endpoints fail
76 // closed without the selector.
77 ...(identity.headers ?? {}),
78 "content-type": "application/json",
79 origin: new URL(target.baseUrl).origin,
80 },
81 body: JSON.stringify(body),
82 });
83 if (!response.ok) {
84 throw new Error(`${path} failed (${response.status}): ${await response.text()}`);
85 }
86 return response;
87 });
88
89/** The identity re-bound to the refreshed session cookie a response set,
90 * scoped to `orgSelector` via the selector header (see switchOrg). */

Callers 2

joinOrgFunction · 0.70
createAnotherOrgFunction · 0.70

Calls 2

textMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected