Why you should start using Nest JS in 2022?

Yaman Omar Alashqar
3 min readFeb 18, 2022

--

What is Nest JS?

Nest JS was developed with a mission to build effective, scalable backend apps with the support of JavaScript/TypeScript.

With the help of the Nest CLI developers can quickly create modules, controllers, pipes, and middleware without pain and therefore it boosts productivity, and automates many of the routine tasks.

Why Nest JS?

Let me first begin by listing the fundamentals of any backend system, and my review will be based on weather Nest JS covers them or not.

Back-end fundamental areas:

  • Server architecture
  • Database administration
  • Data transportation
  • Security
  • Integrations and third-party libraries (tools) support.

All these areas are well covered and handled using Nest JS (directly from the official documentation following the industries best practices and technologies) .

Next, I will depend on the following criteria to measure the pros and cons:

Architecture / Performance / Documentation / Community / Learning Curve / Testing / Integrations

Architecture:

- Nest JS is a highly opinionated framework, the architecture paths are already built, and the developers follow the provided structure guidelines (The architecture is heavily inspired by Angular’s solid structure).

- In my opinion this makes it easier for the team to understand each others code and find things quickly.

Performance:

- There are two important aspects of software performance: responsiveness and scalability,

- Nest JS is perfect to handle these aspects.

- Nest JS offers compatibility with other libraries, such as Fastify or Express.js out of the box.

Documentation:

Their official documentation covers all the backend aspects I’ve mentioned earlier, using the latest trend technologies and best practices.

Community and Learning Curve:

In a nutshell: Nest JS is the Angular for the backend.

Testing:

You can use any testing framework that you like, as Nest JS doesn’t force any specific tooling, but it provides integration with Jest and Supertest out-of-the-box.

Integrations, Libraries, Security and More:

  • All Node JS packages and integrations are available.
  • Many aspects are ready out-of-the-box, such as: Database (TypeORM), Data Validation, Caching, Task Scheduling, Logging, Cookies, File Upload, Server-Sent Events, Authentication, Authorization, Encryption, Hashing, Helmet, CORS, CSRF, Limiters, GraphQL, WebSockets, Microservices, Redis, MQTT, Kafka …

Framework Structure and Core Concepts:

  • Controller: Route the request to a particular function.
  • Providers: Inject dependencies; this means objects can build various relationships with each other.
  • Services: Responsible for operating the database and running the business logic.
  • Repository: Handle DB data.
  • Guard: User authentication.
  • Pipe: Validate and transform data.
  • Filters: Handle errors
  • Interceptors: Extra logic for requests/responses
  • Module: The module class is the place to connect Services, Controllers

Final Notes:

~ Nest JS adopted both TypeScript and Angular features.

~ Nest JS uses TypeORM which gives leverage to connect with SQL and NoSQL databases.

~ Since Nest Js is an Abstraction over the NodeJS. So we can use NodeJS libraries

~ Nest JS surrounds your route handler body with try catch blocks, and it binds error-handling middleware.

Summary:

If you are a Node JS and TypeScript fan then definitely you should keep Nest JS in your mind for your next project.

And if you are familiar with Angular’s structure and core concepts, you will definitely fall in love with Nest JS.

Resources and References:

Official Docs / Academind YouTube Video (Learn Nest JS from Scratch by building an API) / Traversy Media YouTube Video (Nest JS Crash Course)

--

--

No responses yet