Performance: ConfigModule setup
MEDIUM IMPACT
This affects the initial application startup time and memory usage by loading configuration settings efficiently.
import { ConfigModule } from '@nestjs/config'; import { Module } from '@nestjs/common'; @Module({ imports: [ConfigModule.forRoot({ isGlobal: true })], }) export class AppModule {}
import { readFileSync } from 'fs'; import { Injectable, Module } from '@nestjs/common'; @Injectable() export class ConfigService { private config; constructor() { this.config = JSON.parse(readFileSync('config.json', 'utf-8')); } get(key: string) { return this.config[key]; } } @Module({ providers: [ConfigService], exports: [ConfigService], }) export class ConfigModule {}
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous config file read in service constructor | 0 | 0 | 0 | [X] Bad |
| ConfigModule.forRoot with async loading and global cache | 0 | 0 | 0 | [OK] Good |