NestJS is a framework for building server-side Node applications, written with TypeScript first. Teams pick it over plain Express because it gives every project the same clear structure.
Nest runs on top of an HTTP platform. Express is the default, and a Fastify adapter is also available. On top of that, Nest adds a fixed way to organise code (an opinionated architecture), borrowed from Angular. Its main pieces are:
- modules
- providers
- controllers
- a dependency injection (DI) container. DI means Nest creates your classes and passes them the objects they need.
Plain Express gives you routing and middleware only. It leaves the structure up to you, so every codebase ends up organised differently.
Nest gives a team:
- a shared structure
- built-in DI, which makes classes easy to test and swap
- standard building blocks for cross-cutting concerns: logic that many routes share, like auth or logging. These blocks are guards, pipes, interceptors and exception filters.
- official (first-party) integrations for validation, configuration, TypeORM, GraphQL, WebSockets, microservices and queues
The trade-off: Nest needs more boilerplate code, and it takes time to learn.
- Nest is a framework that runs on top of Express (the default) or Fastify.
- It gives a fixed structure: modules, controllers and providers.
- Built-in dependency injection makes classes easy to test and swap.
- It has standard pieces for shared logic: guards, pipes, interceptors and filters.
- The trade-off is more boilerplate and more concepts to learn.
Read more
- Introduction (https://docs.nestjs.com/)docs.nestjs.com
- Modules (https://docs.nestjs.com/modules)docs.nestjs.com