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

Function organizationsOf

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 3

cookieOfFunction · 0.70
jsonMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected