macstr1k3r / trpc-nestjs-adapter

An adapter, allowing you to use TRPC inside of Nest.JS
158 stars 14 forks source link

added req and res object to context return #4

Closed phaxz10 closed 1 year ago

phaxz10 commented 1 year ago

Snippet

return {
             req,
             res,
             ...userProvidedContext,
             resolveNestDependency,
        };

also added the ability to define types for Req and Res object

export type InferContextType<TContext, TReq = IncomingMessage, TRes = ServerResponse> =
  TContext extends () => any
    ? inferAsyncReturnType<TContext> & NestResolver<TReq, TRes>
    : NestResolver<TReq, TRes>;