import databaseConfig from './config/database.config';
@Module({
imports: [
ConfigModule.forRoot({
load: [databaseConfig],
}),
],
})
export class AppModule {}the registerAs has to be loaded into the configureModule.forRoot by adding it in the the load array.
This is valuable to ensure the registerAs is only applicable for the module only. It is better as most of the config is required for the respective modules only.
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import databaseConfig from './database.config';
@Module({
imports: [ConfigModule.forFeature(databaseConfig)],
providers: [],
exports: []
})
export class CouchdbModule { }
if I have understood correctly
below every number represents a module
if I do
forRoot(databaseConfig)on module1then1, 3, 4can use databaseConfigif I do
forFeature(databaseConfig)on module1then only1can use the databaseConfigif I do
forRoot(databaseConfig)on module0then all can use the databaseConfig