Performance: First NestJS application
This affects server startup time and initial response speed, impacting how fast the first page or API response is delivered to the user.
import { Module } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; @Module({ imports: [], controllers: [AppController], providers: [AppService], }) export class AppModule {}
import { Module } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { HeavyModule } from './heavy.module'; @Module({ imports: [HeavyModule], controllers: [AppController], providers: [AppService], }) export class AppModule {}
| Pattern | Server Startup Time | Initial Response Delay | Resource Usage | Verdict |
|---|---|---|---|---|
| Including heavy modules at startup | High (300-500ms extra) | Delayed by 300-500ms | High CPU and memory | [X] Bad |
| Minimal modules at startup | Low (fast startup) | Minimal delay | Low resource usage | [OK] Good |
import { Controller, Get } from '@nestjs/common';
@Controller()
export class AppController {
@Get()
getHello(): string {
return 'Hello, NestJS!';
}
}import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.listen(3000);
}
bootstrap();Pass the test and this pattern moves unknown