Performance: Custom configuration files
MEDIUM IMPACT
This affects the initial application startup time and memory usage by loading and parsing configuration files.
import { ConfigModule } from '@nestjs/config'; @Module({ imports: [ConfigModule.forRoot({ load: [() => require('./custom-config')], isGlobal: true, })], }) export class AppModule {}
import * as fs from 'fs'; const config = JSON.parse(fs.readFileSync('config.json', 'utf-8')); @Module({ providers: [{ provide: 'CONFIG', useValue: config }], }) export class AppModule {}
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous config file read | N/A | N/A | Blocks event loop delaying LCP | [X] Bad |
| Asynchronous config loading with ConfigModule | N/A | N/A | Non-blocking startup improves LCP | [OK] Good |