(
userId: string,
options: {
readonly workos?: Partial<WorkOSClientService>;
readonly services?: Layer.Layer<
DbService | UserStoreService | WorkOsMirror | MemberDirectory
>;
readonly autumn?: Layer.Layer<AutumnService>;
} = {},
)
| 570 | * layer, so a test can fail one store call on purpose. |
| 571 | */ |
| 572 | const sessionHandler = ( |
| 573 | userId: string, |
| 574 | options: { |
| 575 | readonly workos?: Partial<WorkOSClientService>; |
| 576 | readonly services?: Layer.Layer< |
| 577 | DbService | UserStoreService | WorkOsMirror | MemberDirectory |
| 578 | >; |
| 579 | readonly autumn?: Layer.Layer<AutumnService>; |
| 580 | } = {}, |
| 581 | ) => |
| 582 | HttpRouter.toWebHandler( |
| 583 | HttpApiBuilder.layer(NonProtectedApi).pipe( |
| 584 | Layer.provide(Layer.mergeAll(CloudAuthPublicHandlers, CloudSessionAuthHandlers)), |
| 585 | Layer.provide( |
| 586 | requestScopedMiddleware(Layer.mergeAll(options.services ?? RequestScopedServicesLive)) |
| 587 | .layer, |
| 588 | ), |
| 589 | Layer.provideMerge(SessionAuthLive), |
| 590 | Layer.provideMerge(options.autumn ?? stubAutumn), |
| 591 | Layer.provideMerge( |
| 592 | stubWorkOS({ |
| 593 | ...options.workos, |
| 594 | authenticateSealedSession: () => |
| 595 | Effect.succeed({ |
| 596 | userId, |
| 597 | email: `${userId}@placeholder.test`, |
| 598 | organizationId: null, |
| 599 | } as never), |
| 600 | }), |
| 601 | ), |
| 602 | Layer.provideMerge(HttpServer.layerServices), |
| 603 | Layer.provideMerge(RouterConfigLive), |
| 604 | ), |
| 605 | { disableLogger: true }, |
| 606 | ).handler; |
| 607 | |
| 608 | /** The org row as the mirror holds it, or null once purged. */ |
| 609 | const readOrganization = (org: string) => |
no test coverage detected