@greengreystudio/server-package-nest-settings-manager
v2.1.1
Published
This package is an adaptation of the server-package-settings-manager package for NestJS
Downloads
12
Readme
server-package-nest-settings-manager
This package is an adaptation of the server-package-settings-manager package for NestJS
Installation
npm install @greengreystudio/server-package-nest-settings-manager
Integration
import { ConfigModule, ConfigService } from '@nestjs/config';
import { SettingsManagerModule } from '@greengreystudio/server-package-nest-settings-manager';
@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
SettingsManagerModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => {
return {
cdnUrl: configService.get<string>('SETTINGS_CDN_URL') as string,
defaultConsumer: configService.get<string>(
'SETTINGS_DEFAULT_CONSUMER',
) as string,
version: configService.get<string>('SETTINGS_VERSION') as string,
};
},
}),
],
controllers: [],
providers: [],
})
export class AppModule{
}
Usage
@Injectable()
export class ExampleService {
constructor(private readonly settingsManager: SettingsManagerService){}
async exampleAsyn() {
const exampleConfig = await this.settingsManager.fetchSetting('exampleConfig');
}
async example() {
const exampleConfig = this.settingsManager.getSetting('exampleConfig');
}
async exampleWithIdAlias(id: number) {
const entityConfig = this.settingsManager.getById<TSetting_Entity>('exampleConfig', id);
}
}