// Deployment

Deployment

Taking a generated project to production — environment variables, builds and running the server.


A generated project is a standard Node application, so it deploys anywhere that runs Node — a VM, a container platform, or a managed host.

Environment variables

All configuration is read through the config module, which validates required variables at startup. Set them in your platform's environment (never commit .env). Common ones:

VariablePurpose
MONGODB_URIConnection string for your database
PORTPort the server listens on
NODE_ENVproduction in production
SESSION_SECRETSession signing secret (with auth)

If a required variable is missing, the app fails fast on boot with a clear message — so a misconfigured deploy never limps along in a half-broken state.

Build & run

TypeScript

npm run build   # compile to dist/
npm start       # run the compiled server

JavaScript

npm start

Containerized

If you enabled Docker, build and run the image directly:

docker build -t my-api .
docker run -p 3000:3000 --env-file .env my-api

The configured HEALTHCHECK hits GET /health, and graceful shutdown handles rolling deploys cleanly.

Production checklist

  • Set NODE_ENV=production
  • Provide all required environment variables
  • Use a multi-instance-safe rate-limit store (MongoDB or Redis)
  • Point logging where your platform collects it
  • Swagger UI is disabled in production by default — keep it that way unless you need it
tip

Run your tests and npm run docs -- --check in CI before deploying so a broken build or stale docs never reaches production.