Core & Patterns
Modules, providers, dependency injection, lifecycle, architecture
16 articles
Implementing the Strategy Pattern in NestJS
Writing Clean, Decoupled Code with the Strategy Pattern One of the biggest signs of a mature backend developer is understanding how to decouple high-level…
Building a Standalone NestJS Application for Web Scraping
NestJS is a versatile framework that can go beyond server-based applications. In this guide, we’ll focus on building a NestJS standalone application,…
NestJS Custom Decorators
Decorators are a design pattern that can help us to write cleaner code that adheres to the Single Responsibility Principe and Open-closed Principle. In…
NestJS Domain Driven Design With Class Transformer
This article will show how we can utilize the powerful class-transformer library to implement clean domain-driven code in a NestJS application. By the end, you…
NestJS Factory Method Pattern
In this article, I want to show you how to implement the factory method pattern in NestJS to allow for cleaner code. By the end of this article, you should be…
Understanding the injection scopes
When a NestJS application starts, it creates instances of various classes, such as controllers and services. By default, NestJS treats those classes as…
Replacing Express with Fastify
By default, NestJS uses Express under the hood. Moreover, since Express is very popular, NestJS can choose from a broad set of compatible third-party…
Introduction to feature flags
With feature flags (also referred to as feature toggles), we can modify our application’s behavior without changing the code. In this article, we explain the…
Defining dynamic modules
So far in this series, we’ve defined many different modules that can group provides and controllers. None of them was customizable, though. In this article, we…
Interacting with the application through REPL
The NestJS team officially announced NestJS 9 on July 8th. One of its features is Read-Eval-Print-Loop (REPL) implementation. It is an environment that allows…
Dealing with circular dependencies
We need to watch out for quite a few pitfalls when designing our architecture. One of them is the possibility of circular dependencies. In this article, we go…
Composing classes with the mixin pattern
Inheritance is one of the four pillars of object-oriented programming. JavaScript has the prototype-based inheritance, and with it, one object can acquire…
Introduction to logging with the built-in logger and TypeORM
As our application grows, more and more people start depending on it. At a time like this, it is crucial to ensure that our API works well. To do that, we…
An introduction to CQRS
So far, in our application, we’ve been following a pattern of controllers using services to access and modify the data. While it is a very valid approach,…
Looking into dependency injection and modules
NestJS strives to focus on the maintainability and testability of the code. To do so, it implements various mechanisms such as the Dependency Injection. In…
Controllers, routing and the module structure
NestJS is a framework for building Node.js applications. It is somewhat opinionated and forces us to follow its vision of how an application should look like…