Nest.js is a modern, scalable, and powerful framework for building server-side applications with Node.js. It makes use of several design patterns to help you build maintainable and scalable applications. Some of the most commonly used design patterns in Nest.js include:
-
Dependency Injection: Nest.js makes extensive use of Dependency Injection to manage dependencies in your application. This pattern makes it easy to write modular and testable code.
-
Decorator Pattern: Decorators are used in Nest.js for defining controllers, services, modules, and more. Decorators allow you to add metadata to your code, which Nest.js uses to wire up your application.
-
Factory Pattern: Nest.js makes use of the Factory pattern to create instances of classes. This pattern is used extensively in the module system of Nest.js.
-
Builder Pattern: The Builder pattern is used in Nest.js to create complex objects step by step. This pattern is useful when you need to create an object that requires multiple steps or configurations.
-
Proxy Pattern: The Proxy pattern is used in Nest.js to create proxies for your classes. This pattern is useful for adding additional functionality to your classes without modifying their code directly.
-
Middleware Pattern: The Middleware pattern is used in Nest.js to handle requests and responses. It allows you to add functionality to the request/response pipeline of your application.
These patterns are used extensively in Nest.js and are the building blocks of most Nest.js applications. They help to make the code modular, maintainable, and scalable.
More
https://blog.logrocket.com/understanding-design-patterns-typescript-node-js/#singleton-pattern