I'm trying to load config using ConfigModule as below
ConfigModule.forRoot({
ignoreEnvFile: true,
isGlobal: true,
load: [async () => await fetchConfig(new ServiceConfigurationService())],
}),
Inside ServiceConfigurationService class I want to inject other service class which I have exposed through a npm module. Is there any way to inject service instead through a constructor? I have tried property bases DI, it doesn't work in my case.
as long as you control the initialization of
ServiceConfigurationServiceby yourself, you can use any tool to perform the injection.But if you want to use nestjs's DI container, you must do that through nestjs providers as the docs shown here: https://docs.nestjs.com/providers