diff --git a/packages/server/src/trpc/TRPCContext.ts b/packages/server/src/trpc/TRPCContext.ts index 3f40cf5..e7b6571 100644 --- a/packages/server/src/trpc/TRPCContext.ts +++ b/packages/server/src/trpc/TRPCContext.ts @@ -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 run: ( @@ -16,6 +20,12 @@ export interface TRPCContext { effect: Effect.Effect, options?: Runtime.RunForkOptions, ) => RuntimeFiber - - // req: Request } + + +export type TRPCContextRequest = Data.TaggedEnum<{ + Express: { readonly req: Request } + WebSocket: { readonly req: IncomingMessage } +}> + +export const TRPCContextRequestEnum = Data.taggedEnum() diff --git a/packages/server/src/trpc/TRPCContextCreator.ts b/packages/server/src/trpc/TRPCContextCreator.ts index 9b2e0ee..c856923 100644 --- a/packages/server/src/trpc/TRPCContextCreator.ts +++ b/packages/server/src/trpc/TRPCContextCreator.ts @@ -37,10 +37,11 @@ export module TRPCContextCreator { ) return ({ req }) => ({ + + runtime, run, fork, - // req, }) })) }