Skip to content

Commit f5724bf

Browse files
committed
improve: ContextMaker support Scope
1 parent d83210c commit f5724bf

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

.changeset/lazy-eyes-cry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@effect-app/infra": patch
3+
---
4+
5+
support scope

packages/infra/src/api/routing/DynamicMiddleware.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
22
/* eslint-disable @typescript-eslint/no-unsafe-return */
33
/* eslint-disable @typescript-eslint/no-explicit-any */
4-
import { type Array, type Context, Effect, type Layer, type Request, type S } from "effect-app"
4+
import { type Array, type Context, Effect, type Layer, type Request, type S, type Scope } from "effect-app"
55
import type { RPCContextMap } from "effect-app/client/req"
66

77
import type * as EffectRequest from "effect/Request"
@@ -28,7 +28,7 @@ export type RPCHandlerFactory<CTXMap extends Record<string, RPCContextMap.Any>>
2828
any // smd
2929
>
3030

31-
export type ContextProviderOut<RRet> = Effect<Context.Context<RRet>>
31+
export type ContextProviderOut<RRet> = Effect<Context.Context<RRet>, never, Scope>
3232
export type ContextProviderShape<RRet> = { makeRequestContext: ContextProviderOut<RRet> }
3333

3434
export interface Middleware<

packages/infra/test/controller.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ export class ContextMaker extends Effect.Service<ContextMaker>()("ContextMaker",
3131
strict: false,
3232
effect: Effect.gen(function*() {
3333
yield* SomeService
34+
const SomeContext = Layer.sync(Some, () => new Some({ a: 1 }))
3435
return {
3536
mooo: "moo",
36-
makeRequestContext: Effect.gen(function*() {
37-
return Context.make(Some, new Some({ a: 1 }))
38-
})
37+
makeRequestContext: Layer.build(SomeContext)
3938
}
4039
})
4140
}) {}

0 commit comments

Comments
 (0)