🦅 NestJS
Beginner
What is a Provider/Service in NestJS?
Answer
A Provider is a class decorated with @Injectable() that can be injected as a dependency. Services are the most common type of provider and contain the business logic of your application. Declare a service in a module's providers array; NestJS creates and manages its lifecycle. Inject it into a controller via the constructor: constructor(private usersService: UsersService) {} — NestJS automatically resolves the dependency. Other provider types include repositories, factories, helpers, and custom providers. Services keep controllers clean and business logic testable without HTTP concerns.