Install NestJS CLI globally
npm install -g @nestjs/cli
Create a new NestJS project
nest new <project_name>
Move into the project directory
cd <project_name>
npm run start
Generate a new module (e.g., "users" module)
nest g module users
Generate a new controller inside the users module
nest g controller users
Generate a new service inside the users module
nest g service users
Generate a resource (combination of module, controller, and service)
nest g resource users
Generate a controller with specific routing (e.g., "auth" module)
nest g controller auth --path auth
Generate a provider (custom service)
nest g provider custom-provider
Generate a class (e.g., a utility class)
nest g class utils/logger
nest g interface users/interfaces/user
Generate a guard (for route protection)
nest g guard auth
Generate a pipe (for validation or transformation)
nest g pipe validation
Generate an interceptor (for modifying request/response)
nest g interceptor logging
Generate a filter (for handling exceptions)
nest g filter exceptions
Serve the project (dev mode)
npm run start:dev
Serve the project with a specific port
npm run start -- --port=3001
Build the project (production)
npm run build
npm run test