- NestJS is a framework for building server-side applications in Node.js.
- It's written in TypeScript but supports plain JavaScript as well.
- Wraps mature HTTP server libraries like Express or Fastify.
- Standardizes application architecture around modules, controllers, and providers.
- Leverages TypeScript's type system for compile-time safety and clear APIs.
- Offers built-in support for validation, configuration, and testing.
- Encourages a declarative, layered approach rather than manual middleware stitching.
- Uses dependency injection via an IoC container for clean, reusable classes.
- Provides a CLI tool for project scaffolding and code generation.
// Basic NestJS application structure
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
imports: [],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}