Performance: Environment variables
LOW IMPACT
Environment variables affect application startup time and configuration loading, impacting initial page load speed and server response readiness.
import { Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; @Module({ imports: [ConfigModule.forRoot({ isGlobal: true })], }) export class AppModule {}
import * as dotenv from 'dotenv'; dotenv.config({ path: './.env' }); // Access process.env directly throughout the app
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous dotenv.config() on every import | N/A | N/A | Delays server response, increasing LCP | [X] Bad |
| NestJS ConfigModule with global loading | N/A | N/A | Fast server startup, minimal LCP impact | [OK] Good |