Dave
Dave

Reputation: 362

Is it possible to create a custom provider that is also request scoped?

I'd like to create a custom provider for a request-scoped resource, combining these styles:

https://docs.nestjs.com/fundamentals/custom-providers#use-factory https://docs.nestjs.com/fundamentals/injection-scopes#request-provider

I'm not sure if it's possible, or what the correct markup of the custom provider is if so.

Upvotes: 2

Views: 736

Answers (1)

Adrien De Peretti
Adrien De Peretti

Reputation: 3672

In fact you can do that by passing the scope property along the factory

Here is the link to the interface https://github.com/nestjs/nest/blob/master/packages/common/interfaces/modules/provider.interface.ts

Upvotes: 2

Related Questions