I'm working with nx workspace and nestjs. I would like to inject a value across multiple modules in nestjs app.
Final goal is to reproduce similar way of configuration management as vsavkin mentioned for Angular
But it seems it's not possible, or I missed something.
Nest can't resolve dependencies of the FeatureService (?). Please make sure that the argument at index [0] is available in the FeatureModule context.
How can I notify FeatureModule
it needs to access to this global injected value ?
This is working fine inside AppService
(service in root module), but not in any sub modules.
Here is my code below. Or an full example on codesandbox.io
app.module.ts
@Module({
imports: [
FeatureModule
],
controllers: [
AppController
],
providers: [
AppService,
{
provide: 'MY-TOKEN',
useValue: 'my-injected-value',
}
],
})
export class AppModule {}
feature.module.ts
@Module({
imports: [],
controllers: [],
providers: [
FeatureService
],
})
export class FeatureModule {
}
feature.service.ts
@Injectable()
export class AppService {
constructor(
@Inject('MY-TOKEN') private injectedValue: string
) {}
}