MCPcopy Create free account
hub / github.com/effect-app/libs / MyContextProvider

Class MyContextProvider

packages/infra/test/controller.test.ts:20–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18import { AllowAnonymous, AllowAnonymousLive, CustomError1, RequestContextMap, RequireRoles, RequireRolesLive, Some, SomeElse, SomeService, Test, TestLive } from "./fixtures.js"
19
20class 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
51class MyContextProvider3 extends RpcX.RpcMiddleware.Tag<MyContextProvider3, {
52 provides: Some

Callers

nothing calls this directly

Calls 1

makeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…