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

Function organizationsOf

e2e/cloud/support/session.ts:191–207  ·  view source on GitHub ↗
(
  target: TargetShape,
  identity: Identity,
)

Source from the content-addressed store, hash-verified

189
190/** Every org this account is a member of, plus the one the session is on. */
191export const organizationsOf = (
192 target: TargetShape,
193 identity: Identity,
194): Effect.Effect<{
195 readonly organizations: ReadonlyArray<{ readonly id: string; readonly slug: string }>;
196 readonly activeOrganizationId: string | null;
197}> =>
198 Effect.promise(async () => {
199 const response = await fetch(new URL("/api/auth/organizations", target.baseUrl), {
200 headers: { cookie: cookieOf(identity) },
201 });
202 if (!response.ok) throw new Error(`/api/auth/organizations failed (${response.status})`);
203 return (await response.json()) as {
204 organizations: ReadonlyArray<{ id: string; slug: string }>;
205 activeOrganizationId: string | null;
206 };
207 });

Callers 1

Calls 3

cookieOfFunction · 0.70
jsonMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected