Skip to content

Nest.js is interesting

Published: at 07:21 PM

A little background

Our engineering team at Sigtech has decided to rewrite all our microservices as a part of the second iteration. Why a rewrite, you say? Because the tech stack heavily relied on Serverless as a solution and it came to bite the team back after 3 years. How did this happen? As and when the user base increases, you realize something which is painful. Lambdas aren’t cheap, in fact they’re bloody expensive.

So here I am, given duties of rewriting some of the core components keeping scalability & performance in mind.

Why Nest.js? Hell! Why even think of Node at all?

I have been writing APIs in Node for a little over 2 years now. Is it the best thing available out there? Probably not. You might argue saying Go with Gin might be more performant. However, I choose Node because everything is in the Javascript ecosystem & it helps me quickly iterate on frontend work with React. Yes, guilty as charged. I prefer Node just because of the convenience it offers.

What did I like about Nest.js?

Express.js is my go-to framework for hosting a quick and simple REST API. I’d use this without any particular design pattern in my pet project’s codebase. However, that isn’t the case when you write code for any company. There are rules, guidelines etc. for you to follow so that the code is “readable” by all engineers alike.

Nest.js is like a nice bootstrap template over Express.js. Their main selling point is Dependency injection Omega lol who gives a shit about dependency injection in a language like JS where I can write re-usable modules.

Refactoring guru is an amazing collection of docs around different design patterns. And they’re all free!!

The authors encourages us to stick and adhere to a design pattern/principle & provides neat abstractions, routing and other essentials that are needed for hosting a REST API. They promote the use of ES6 components like class decorators which are heavily used within Nest.js.

I’d recommend Nest.js