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

Function activeOrg

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

Source from the content-addressed store, hash-verified

172
173/** The org this identity's session is currently bound to: id and URL slug. */
174export const activeOrg = (
175 target: TargetShape,
176 identity: Identity,
177): Effect.Effect<{ readonly id: string; readonly slug: string }> =>
178 Effect.promise(async () => {
179 const response = await fetch(new URL("/api/auth/me", target.baseUrl), {
180 headers: { cookie: cookieOf(identity) },
181 });
182 if (!response.ok) throw new Error(`/api/auth/me failed (${response.status})`);
183 const body = (await response.json()) as {
184 organization: { id: string; slug: string } | null;
185 };
186 if (!body.organization) throw new Error("identity has no active organization");
187 return { id: body.organization.id, slug: body.organization.slug };
188 });
189
190/** Every org this account is a member of, plus the one the session is on. */
191export const organizationsOf = (

Calls 3

cookieOfFunction · 0.70
jsonMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected