NestJS Basic Starter
Basic Information of NESTJS MVC code Structure
controllers are basically handles all the incoming routes
services/providers will handle logic behind routes
# Installationinstall cli globly
npm i -g @nestjs/cli
create new project in nestjs
nest new .
choose whatever npm,yarn or pnpm (i choose pnpm)
pnpm i
development mode
pnpm run start
watch mode
pnpm run start:dev
production mode
pnpm run start:prod
unit tests
pnpm run test
e2e tests
pnpm run test:e2e
test coverage
pnpm run test:cov
add module with name users or any other module
nest g module users
add controllers for users or any other controllers
nest g controller users
add services for users or any other services
nest g service users
add .env.development or .env.test.local for development and production respectively
PORT = 7164
add config module in app.module.ts typescript will automatically look up the environment variables from .env file
pnpm add -D @nestjs/config
Creating nest resouces
nest g resource auth --no-spec