Skip to content

Commit 940f9a0

Browse files
committed
chore: flat contextmaker again
1 parent 96ff405 commit 940f9a0

4 files changed

Lines changed: 9 additions & 7 deletions

File tree

.changeset/evil-kiwis-switch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@effect-app/infra": minor
3+
---
4+
5+
flat ContextMaker again

packages/infra/src/api/routing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,5 +907,5 @@ export const RequestCacheLayers = Layer.mergeAll(
907907

908908
export class DefaultContextMaker extends Effect.Service<DefaultContextMaker>()("DefaultContextMaker", {
909909
strict: false,
910-
succeed: { makeRequestContext: Effect.succeed(Context.empty()) } satisfies ContextProviderShape<never>
910+
succeed: Effect.succeed(Context.empty()) satisfies ContextProviderShape<never>
911911
}) {}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export type RPCHandlerFactory<CTXMap extends Record<string, RPCContextMap.Any>>
2929
>
3030

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

3434
export interface Middleware<
3535
MiddlewareContext,
@@ -89,7 +89,7 @@ export const makeRpc = <
8989
const h = execute(schema, handler, moduleName)
9090
return (req: Req, headers: any) =>
9191
Effect.gen(function*() {
92-
const ctx = yield* contextProvider.makeRequestContext
92+
const ctx = yield* contextProvider
9393
return yield* h(req, headers).pipe(
9494
Effect.provide(ctx),
9595
Effect.uninterruptible // TODO: make this depend on query/command, and consider if middleware also should be affected or not.

packages/infra/test/controller.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ export class ContextMaker extends Effect.Service<ContextMaker>()("ContextMaker",
3232
effect: Effect.gen(function*() {
3333
yield* SomeService
3434
const SomeContext = Layer.sync(Some, () => new Some({ a: 1 }))
35-
return {
36-
mooo: "moo",
37-
makeRequestContext: Layer.build(SomeContext)
38-
}
35+
return Layer.build(SomeContext)
3936
})
4037
}) {}
4138

0 commit comments

Comments
 (0)