https://docs.nestjs.com/
- Install Global CLI ( Command Line Interface )-
npm i -g @nestjs/cli
- since we Installed cli we can create nestjs project using -
- Next we have to select the package Manager

- Done πΒ - our setup is ready now.
- Intial folder structure

- main.ts β Root File ( Entry Point ) - creates a Instance of NestJS
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(process.env.PORT ?? 3000);
}
bootstrap();
- app.module.ts β Connects all the Submodules
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
imports: [],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
- app.controller.ts β Handles Requests and Responses
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
getHello(): string {
return this.appService.getHello();
}
}
- app.service.ts β Place where we write our logics
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}
}
- Now lets dive into them one by one by creating small project
- NestCLI Is Very Powerful - so letβs start
- create a new module, controller and service with name hello