पाठ 26 / 33

Deployment

NestJS apps को production में deploy करें—build, optimize, और run करें।

Production के लिए build करें

TypeScript को JavaScript में compile करें; unused code को tree-shake करें।

npm run build
ls dist/  # compiled JS output

Production में run करें

NODE_ENV=production को dist/ folder में point करें; optionally PM2 जैसे process manager का उपयोग करें।

NODE_ENV=production node dist/main.js

# or with PM2
pm2 start dist/main.js --name "nestjs-app"

Health check endpoint

Load balancers और orchestrators को poll करने के लिए /health या /ping endpoint जोड़ें।