How to use configurable module builders in NestJS v9
Blog post from LogRocket
NestJS is a TypeScript-based web framework that incorporates object-oriented programming principles, offering features such as dependency injection, encapsulation, classes, and decorators. It is particularly accessible to developers with backgrounds in Java or ASP.NET, thanks to its familiar structure and syntax, reminiscent of Angular. The framework emphasizes the use of modules, which are encapsulated pieces of code that can be reused throughout an application, enhancing development speed and modularity. NestJS uses singletons for module management, with three primary injection scopes: request-level, component-level (transient), and shared application-level (global) modules. The use of global modules, while practical for certain functions like logging, can lead to data race conditions, which necessitates careful management of module states. NestJS also supports dynamic modules, which are configurable and can adapt based on parameters provided at initialization, utilizing the factory pattern to create flexible, non-static modules. The framework allows for straightforward creation and customization of modules, enabling developers to build scalable, efficient applications.