Questions tagged [nestjs-providers]

6 questions
3
votes
0 answers

Create array of providers from Dynamic Module options

I am working with NestJS and I am building re-usable modules, configurable via forRoot and forRootAsync static methods. I am looking for a way to provide multiple providers of the same class, based on the module options. export type MyModuleOptions…
3
votes
0 answers

Nestjs dependency injection order when a module depends on a Mongoose model from @nestjs/mongoose, detailed diagram inside

The diagram does a good job at explaining the flow I currently have and why that is failing. I have logger.module that exports a loger.service that depends on a @nestjs/mongoose LogModel. I have a db.module that exports session.service and imports…
SebastianG
  • 8,563
  • 8
  • 47
  • 111
2
votes
1 answer

Nestjs wrapping external module in forRootAsync and inject instance

I've been developing a wrapper module for nestjs based on a nodejs module. I created a static forRoot method in order to get the configuration. I created such a prodiver within the forRoot method: const MyProvider = { provide: PROVIDER_TOKEN, …
Vahid Najafi
  • 4,654
  • 11
  • 43
  • 88
1
vote
1 answer

NestJS v9: implement durable providers

[SOLVED] I'm pretty new to NestJS and trying to get my head around durable providers but i can't get them to work. My scenario is that i have a service with some logic and two providers that implement the same interface to get some data. Depending…
mago
  • 11
  • 3
1
vote
1 answer

Nestjs instantiate class of services in useFactory

I was checking one of the nestjs module's source code (nestjs-firebase-admin) and I saw something weird. In this line: private static createProviders(app: admin.app.App): Provider[] { return PROVIDERS.map((ProviderService) => ({ …
Vahid Najafi
  • 4,654
  • 11
  • 43
  • 88
0
votes
1 answer

Inject provider in decorator function

Basically, I need to pass an authService to the "verifyClient" function inside the @WebSocketGateway decorator, like so : @WebSocketGateway({ transports: ['websocket'], verifyClient: (info: { req: IncomingMessage }, done: (result: boolean, code:…