( target: TargetShape, identity: Identity, )
| 187 | |
| 188 | /** Every org this account is a member of, plus the one the session is on. */ |
| 189 | export 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 | }); |
no test coverage detected