TRPCContextRequest
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import type { TRPCError } from "@trpc/server"
|
||||
import type { Effect, Runtime } from "effect"
|
||||
import { Data, type Effect, type Runtime } from "effect"
|
||||
import type { RuntimeFiber } from "effect/Fiber"
|
||||
import type { Request } from "express"
|
||||
import type { IncomingMessage } from "node:http"
|
||||
import type { Services } from "../Services"
|
||||
|
||||
|
||||
export interface TRPCContext {
|
||||
req: TRPCContextRequest
|
||||
|
||||
runtime: Runtime.Runtime<Services>
|
||||
|
||||
run: <A, E>(
|
||||
@@ -16,6 +20,12 @@ export interface TRPCContext {
|
||||
effect: Effect.Effect<A, E, Services>,
|
||||
options?: Runtime.RunForkOptions,
|
||||
) => RuntimeFiber<A, TRPCError>
|
||||
|
||||
// req: Request
|
||||
}
|
||||
|
||||
|
||||
export type TRPCContextRequest = Data.TaggedEnum<{
|
||||
Express: { readonly req: Request }
|
||||
WebSocket: { readonly req: IncomingMessage }
|
||||
}>
|
||||
|
||||
export const TRPCContextRequestEnum = Data.taggedEnum<TRPCContextRequest>()
|
||||
|
||||
@@ -37,10 +37,11 @@ export module TRPCContextCreator {
|
||||
)
|
||||
|
||||
return ({ req }) => ({
|
||||
|
||||
|
||||
runtime,
|
||||
run,
|
||||
fork,
|
||||
// req,
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user