Node.js Framework Series— 1. NestJS

NestJS: A progressive Node.js framework for building efficient, reliable and scalable server-side applications.

A progressive Node.js framework for building efficient, reliable and scalable server-side applications.

NestJS is a backend framework for creating scalable applications and is a platform-agnostic framework. Therefore, we can create reusable components and can take advantage of different types of libraries and applications. It works as an abstraction over the underlying HTTP server library. Currently, it supports two libraries — Express[1] and Fastify[2] — while still enabling developers to use their own APIs when needed. According to your application needs, you can choose one of them. But by default, it uses express libraries as a platform as you see in a package.json .

· A platform-express package: Express is a minimal and flexible Node.js web framework for Node.js. It is mature, robust production-ready library with lots of HTTP methods and middleware. Most of the Node.js frameworks[3] are built on it. The @nestjs/platform-express package is used by default.

· A platform-fastify package: Fastify is a web framework highly focused on providing the best developer experience with the least overhead and a powerful plugin architecture. It is inspired by Hapi[4] and Express and as far as we know, it is one of the fastest web frameworks in town[5]. To see, how to use it, please refer to

Whichever platform is used, it uses its own application interface and these are respectively as NestExpressApplication and NestFastifyApplication.

Express, Koa[6], hapi, fastify don’t enforce us to use any particular architecture. They provide lower-level set of tools, sure they are giving us many ready-use robust methods and middleware, but as developers, we need to do more for our scalable, maintainable, testable application. If we made a mistake at the beginning of a project regarding the architecture, it may cost a lot, we may spend lots of time for refactoring the code later.

NestJS, in contrast, forces developers to use an architecture by introducing Angular-like modules, controllers, services and ensuring the application is scalable, testable, maintainable and decoupled. NestJS is really strict and well defined for the application development with its component-based approach.

To work in a project as a team needs some standardisations. Developers have many alternative ways for the project skeleton, design patterns, developments or regarding how a project should be structured. All of these preferences won’t provide an healthy development environment. Instead, they will cause a mess and overall poor code quality.

NestJS, to combat this, provides a standardised set of guidelines by defining an opinionated architecture that each developer in the team has to follow. At the end we have maintainable codebase with it.

Let’s explain how NestJS is using them in two major architecture sections as shown below:

· Lifecycle events

· Building Blocks

All of the sections about NestJs Framework


[1] Express, Official website, 2020, available at

[2] Fastify, Office website, 2020,

[3] Frameworks built on Express, 2020, available at

[4] Hapi, Official website, 2020, available at

[5] Fastify, Why, 2020, available at

[6] Koa, Official website, 2020, available at

Technical Training Coordinator at www.Zero2Hero.Training, Blockchain Developer(Oxford BC Strategy Programme Certified) and an AWS Certified Solution Architect.