Router work

This commit is contained in:
Julien Valverdé
2024-07-05 19:31:35 +02:00
parent a49843ec89
commit bb1a422097
4 changed files with 17 additions and 19 deletions

View File

@@ -1,12 +1,14 @@
import type { Effect } from "effect"
import type { Effect, Runtime } from "effect"
import type { Request } from "express"
import type { Services } from "../Services"
export interface TRPCContext {
req: Request
runtime: Runtime.Runtime<Services>
run: <A, E>(
effect: Effect.Effect<A, E, Services>,
options?: { readonly signal?: AbortSignal }
) => Promise<A>
req: Request
}

View File

@@ -13,13 +13,13 @@ export class TRPCContextCreator extends Context.Tag("TRPCContextCreator")<TRPCCo
export module TRPCContextCreator {
export const Live = Layer.effect(TRPCContextCreator, Effect.gen(function*() {
const run = yield* Effect.runtime<Services>().pipe(
Effect.map(Runtime.runPromise)
)
const runtime = yield* Effect.runtime<Services>()
const run = Runtime.runPromise(runtime)
return ({ req }) => ({
req,
runtime,
run,
req,
})
}))
}