Installing the NestJS CLI (command-line interface)
Installing Node.js
Install NestJS CLI -globally
Generating Nest JS Application
What’s inside a Nest JS Application
2. Creating a REST API application
Prerequisite: Install Insomnia/Postman
Creating a Basic Controller
nest generate controller
Use Route Parameters
Handling Request Body / Payload
Response Status Codes
Handling Update and Delete Requests
Implement Pagination with Query Parameters
Creating a Basic Service
nest generate service {name}
Send User-Friendly Error Messages
Encompass Business-Domain in Modules
controllers - Which you can think of as our API Routes, that we want this module to instantiate.
exports - Here we can list providers within this current module that should be made available anywhere this module is imported
imports - Just as we saw in the AppModule, the imports Array gives us the ability to list OTHER modules that THIS module requires. Any exported providers of these imported modules are now fully available here as well.
providers - Here we’re going to list our services that need to be instantiated by the Nest injector. Any providers here will be available only within “THIS” module itself, unless added to the exports array we saw above.
Introduction to Data Transfer Objects
Generate a DTO class with the Nest CLI
nest g class coffees/dto/create-coffee.dto --no-spec
Validate Input Data with Data Transfer Objects
ValidationPipe
Install needed dependencies - npm i class-validator class-transformer