Why use the NestJS framework?

As a front-end developer, I would like to say that the NestJs framework was the best choice to start touching the backend part of the applications. I was always asking my tutor at Apiumhub about design patterns, clean architecture and microservices. Then he showed me a link to the completely complete and very well structured documentation of NestJs. It was a good discovery for me to get lost on this page and learn about decorators, providers, dependency injection, testing, authentication and more topics from different fields.

What is NestJs?

First of all, what is this NestJs? this one open source Node.js framework for developing challenging backend systems that use the design paradigm Convention over configuration Which eliminates the need for explicit configuration by allowing developers to use common tools and code in a particular way.

You can build scalable, testable and loosely coupled applications. it’s very impressed Angular And an important feature is the power of dependency injection, which allows one module to be injected into another, promoting code reuse.

What does NestJ provide and what are the benefits of using it?

NestJs are built for both monolith and microservices. You can create REST API, MVC application, GraphQL application, Web Socket or CLI and CRON job.

Since Nest applications are written in TypeScript, error detection at compile time protects our code and avoids errors when writing multiple microservices that all have the same response mode.

NestJS makes it possible to build excellent, streamlined and lightweight microservices. Due to the framework imposed by NestJs, developers have to write controllers, services, and repositories in specific places and in specific ways. This improves the development process as it prevents mistakes that can result in a lot of effort remodeling the codebase later on and allows to focus more on the design of the endpoint rather than the application structure.

It has a useful command-line interface tool called NestCLI that facilitates the creation of boiler code (modules, middleware, controllers, etc.). Also, TypeScript, prettier and eslint configurations are fully installed with NestJS.

It provides integration with Jest and Supertest, and by the dependency injection mechanism, it makes mocking components in a test environment easy.

The documentation of NestJs is the most thorough and understandable by quickly scanning the documents, you can find the answer to your bug and reduce the time spent on debugging.

Fundamental Concepts of NestJs


A decorator is an expression that accepts three arguments: a target, a name, and a property descriptor, and returns a function. You implement this by putting a decorator on top of whatever you’re trying to decorate, followed by the @ character. There are three different decorators such as square ( @controller() ), method( @Received() ), or argument ( @Body() ,

Everything can be controlled with decorators in NestJ. You can attach a controller to a collection of routes, specify request methods, add request body content, or parse request parameters. You can also create your own custom decorators to use inside your project. Like in the NestJs Documentation example:


Controllers handle incoming requests and return responses to the client. You can specify a URL for this controller as the main route and use the @Controller decorator as a method decorator, such as @Get, @Post, @Put, or @Delete.


Providers are an essential concept in NestJs. Core nested classes, such as services (handles data access and business logic), repositories (handles access to databases), factories, etc., can be considered as providers. It is possible to create new providers and inject them into controllers or existing providers. For example, a service provider would be used with an @Injectable decorator that adds metadata and declares that the service can be managed by a Nest IoC container. Nest IoC manages the interactions between service providers.

Sk0alSKcYc9a6UFOUQFEU6grYq22AH0cDuZAFvjE7jaH J984Tm 6X73aVkP4z7y1DDF1zShmrLUP2sdJVH0kPUm1MJR55qzmJ1jT yuAipX9QhHWajFOnMUCjwOmvZc vVEAeIZajT9ak9LTnmQO eUUpYnFReK1SpADbMzTCA9aXEuWv98nUGz3ZbY3g

by Stephen Grider ,NestJS: The Complete Developer’s Guidecourse


Modules are the fundamental building pieces of nested applications. The AppModule is automatically included when you build a nested application. To organize your components effectively, it is recommended that you group each of your features into a single module.

By default, modules include providers. As a result, providers that are neither directly part of the current module nor directly exported from an imported module cannot be injected.


There are two common uses for pipes: to transform input data into the desired form and to validate it by throwing an exception if it is invalid.


Guards decide whether a specific request will be processed by the route handler based on particular run-time conditions. They help in setting up the authentication and authorization logic easily.


In this article, we’ve recapitulated some of the key ideas from NestJs. With NestJs you can create clear boundaries domain-wise, write reusable modules, and write loosely coupled and maintainable code. It is unbelievable how many decorators are available in this framework which require minimal or no coding to perform various tasks. Additionally, dependency injection makes it easy to mock services, for example, in your controller tests.

NestJs has a large community and good documentation to explore on their website. Additionally, I’ve included a colleague’s Spanish NestJs tutorial that illustrates the key ideas with concrete examples and lists useful tools and libraries to use with NestJs.


Leave a Comment