NestJS is a framework designed to make life easier for developers, using the right architectural approaches and dictating its own rules.
Therefore, NestJS is not only a backend framework, but also an opportunity to enter the world of advanced concepts, such as DDD, Event sourcing and microservice architecture. Everything is packaged in a simple and lightweight way, so the choice is yours – whether you decide to use the entire platform or just use its components.
It’s called “Angular in the backend world”, and it’s true, because the developers were inspired by Angular.
The framework has a great CLI, a structure in which there is no room for error, good documentation where you can find examples of most use cases.
Another interesting fact is that under the hood, Nest is able to use various low-level frameworks, out of the box it is Express, but you can easily switch to, for example, Fastify.
What does NestJS consist of?
The author of the framework was inspired by the ideas of Angular, and NestJS turned out to be very similar to Angular, especially in early versions.
Controllers
The controller layer is responsible for processing incoming requests and returning a response to the client.
Providers
Almost everything is a Provider – Service, Repository, Factory, Helper, etc. They can be embedded in controllers and other providers.
Modules
A module is a class with a @Module() decorator. The @Module() decorator provides the metadata that Nest uses to organize the structure of an application. Every Nest application has at least one module, the root module. The root module is where Nest begins to organize the application tree. In fact, the root module may be the only module in your application, especially when the application is small, but that doesn’t make sense. In most cases, you’ll have multiple modules, each with a closely related set of capabilities. In Nest, modules are singletons by default, so you can easily share the same component instance between two or more modules.
Exception Filters
Nest has an exception layer that is responsible for catching unhandled exceptions and returning the appropriate response to the end user.