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

Function postJson

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

Source from the content-addressed store, hash-verified

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

Callers 1

joinOrgFunction · 0.70

Calls 2

textMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected