all, how to use DynamicModule in config case?
https://github.com/nestjs/nest/blob/master/sample/25-dynamic-modules/src/config/config.service.ts#L12 for official example.
After config like official Example:
import { Inject, Injectable } from '@nestjs/common';
import * as dotenv from 'dotenv';
import * as fs from 'fs';
import * as path from 'path';
import { CONFIG_OPTIONS } from './constants';
import { ConfigOptions, EnvConfig } from './interfaces';
@Injectable()
export class ConfigService {
private readonly envConfig: EnvConfig;
constructor(@Inject(CONFIG_OPTIONS) options: ConfigOptions) {
const filePath = `${process.env.NODE_ENV || 'development'}.env`;
const envFile = path.resolve(__dirname, '../../', options.folder, filePath);
this.envConfig = dotenv.parse(fs.readFileSync(envFile));
}
get(key: string): string {
return this.envConfig[key];
}
}
Really don't understand "Dynamic modules give us the ability to pass parameters into the module being imported so we can change its behavior. "(from official docs) Any difference to common ways? Like:https://docs.nestjs.com/techniques/configuration
For example, If I have two of three config file in config folder. How to use? And difference between the common ways.
Thanks.