First Steps and Core Concepts
In this documentation we will go through the basic concepts and recommended file structure of this adapter, our main goal developing this adapter was to make it synonymous with NestJS and it's opinionated approach and concepts.
đź’ˇ
If you are looking for an installation guide for this adapter, check out our Setup Guide.
Basic File Structure
In NestJS tRPC we take a similar approach to how NestJS implements it's routing system, meaning the file structure should remain similar.
- app.router.ts
- app.middleware.ts
- app.context.ts
- app.service.ts
- app.module.ts
- main.ts
Here's a brief overview of those core files:
app.router.ts | Comparable to a NestJS controller, a basic router with a single route. |
app.middleware.ts | Comparable to a NestJS guards or middlewares, its a middleware that can modify the request ctx. |
app.context.ts | A context class that modifies the application context. |
app.service.ts | A basic service, The same service you will use in any NestJS application. |
app.module.ts | The root module of the application. |
main.ts | The entry file of the application which uses the core function NestFactory to create a Nest application instance. |
Platform
As of writing, we have native support for both the express
and the fastify
drivers, the adapter checks which driver you are currently using and adapts accordingly.