I'm trying to instance a service with arguments when using the payload received. Ideally I'd like to do this in a more controlled DI responsible way but not sure of the correct approach. Ref code:
// inside controller
public async handleRequest(
@Body() requestDto: RequestDTO
): Promise<void> {
this.newService = new NewService(
API_KEYS.get(requestDto.address.country)
);
await this.newService.triggerBoarding(requestDto);
}
This means the service I use in my NewService also has to know about the argument:
constructor(apiKey: string) {
this.outletService = new OutletService(apiKey);
}
Would this be a case for lazy loading and using moduleRef?