Open jeffthompson1971 opened 1 year ago
TRPCModule.forRoot
in your app module as shown in the example.init-trpc
and put it somewhere central. You should export type Router = typeof appRouter
here (this is missing in the example but it is assumed you understand this, as it is the main requirement of tRPC that is covered in their great documentation.)init-trpc
, in each procedure you can resolve any service class you wish that has the actual business logic you route to (as shown with ctx.resolveNestDependency(AService)
). This particular step is why this adapter exists, to allow you to use nest's dependency injection in your routes.init-trpc
via providing a list of routes in each of your modules (eg. user/user.routes.ts), then importing them all back up to the init-trpc
level where you actually create the router out of all of them (you can use tRPC.mergeRouters or nest them in namespaces, see tRPC docs). The main requirement of tRPC is that you combine all your routes into a router and export its type for your front-end to use. When you import the type of the router only, your front end does not include any server side code in the bundle, as typescript types get stripped.
Hi. I want to use this and try it out but i don't know how to use it exactly.. i see an example folder, so do i need to copy that whole folder including the /lib into my project? Or how does this work? I don't see how to run the example you have to see it working. Should I be able to?