| 18 | import { AllowAnonymous, AllowAnonymousLive, CustomError1, RequestContextMap, RequireRoles, RequireRolesLive, Some, SomeElse, SomeService, Test, TestLive } from "./fixtures.js" |
| 19 | |
| 20 | class MyContextProvider extends RpcX.RpcMiddleware.Tag<MyContextProvider, { |
| 21 | provides: Some |
| 22 | requires: SomeElse |
| 23 | }>()("MyContextProvider") { |
| 24 | static Default = Layer.make(this, { |
| 25 | *make() { |
| 26 | yield* SomeService |
| 27 | if (Math.random() > 0.5) return yield* new CustomError1() |
| 28 | |
| 29 | return Effect.fnUntraced(function*(effect) { |
| 30 | yield* SomeElse |
| 31 | // the only requirements you can have are the one provided by HttpLayerRouter.Provided |
| 32 | yield* Scope.Scope |
| 33 | |
| 34 | yield* Effect.logInfo("MyContextProviderGen", "this is a generator") |
| 35 | yield* Effect.succeed("this is a generator") |
| 36 | |
| 37 | // this is allowed here but mergeContextProviders/MergedContextProvider will trigger an error |
| 38 | // yield* SomeElse |
| 39 | |
| 40 | // currently the effectful context provider cannot trigger an error when building the per request context |
| 41 | // this is allowed here but mergeContextProviders/MergedContextProvider will trigger an error |
| 42 | // if (Math.random() > 0.5) return yield* new CustomError2() |
| 43 | |
| 44 | return yield* Effect.provideService(effect, Some, Some.of({ a: 1 })) |
| 45 | }) |
| 46 | } |
| 47 | }) |
| 48 | static but_why = "???" // remove me and life rocks |
| 49 | } |
| 50 | |
| 51 | class MyContextProvider3 extends RpcX.RpcMiddleware.Tag<MyContextProvider3, { |
| 52 | provides: Some |
nothing calls this directly
no test coverage detected
searching dependent graphs…