DEV Community

fadow
fadow

Posted on

How I Ship a Production NestJS Backend in Under 30 Minutes

Every new project used to take me 2-3 days of setup before I wrote a single line of business logic.

Auth. i18n. MongoDB. Redis. Docker. Swagger. Tests. Every. Single. Time.

Here's the stack I landed on after 6 projects:

The Setup

1. One command to run everything

# docker-compose.yml
services:
  app:
    build: .
    ports: ["3000:3000"]
  mongo:
    image: mongo:7
    ports: ["27017:27017"]
  redis:
    image: redis:7-alpine
    ports: ["6379:6379"]
Enter fullscreen mode Exit fullscreen mode
docker compose up -d
Enter fullscreen mode Exit fullscreen mode

3 services. Zero config drift between my machine and production.

2. Auth that doesn't leak

JWT access tokens (15min) + refresh tokens (7 days, hashed in DB). Logout invalidates both — refresh token deleted from DB, access token blacklisted in Redis. No dangling sessions.

3. i18n from day one

Vietnamese users deserve proper tone marks. Two JSON files, one auto-detect from Accept-Language, one translation function. Not a 500KB library. Just ~50 lines.

{ "email_invalid": "Email không hợp lệ" }
{ "email_invalid": "Invalid email address" }
Enter fullscreen mode Exit fullscreen mode

4. Validation that actually validates

ValidationPipe({ whitelist: true, forbidNonWhitelisted: true }) — one line. No more unexpected fields in your DTOs. If your API crashes in dev, it crashes the same way in prod.

5. Tests that prove it works

36 tests. Auth flow. User CRUD. i18n responses. RBAC guards. Not "it compiled, ship it." Actually verified.

The Math

At 2h/day of freelance time, setup costs ~$25/hour:

  • Auth + RBAC: 2 hours = $50
  • i18n: 1 hour = $25
  • Docker setup: 30 min = $12.50
  • Tests: 2 hours = $50
  • Swagger docs: 30 min = $12.50

That's $150 in setup costs per project.

The Shortcut

I packaged this exact setup into a starter kit. Clone, .env, docker compose up -d. 30 minutes instead of 2 days.

https://fadow.gumroad.com/l/nestjs-starter-kit-vietnam

Bilingual Vietnamese + English. 36 passing tests. Docker-ready. $10.


What's your NestJS setup ritual? Drop it below.

Top comments (0)