- Structured logging
- Log JSON with Pino (nestjs-pino integrates it), include a request or trace ID on every line, and use levels consistently. Never log secrets, tokens or personal data; redact by path in the logger config.
- OpenTelemetry traces and metrics
- OpenTelemetry is the vendor-neutral standard for traces, metrics and logs; the Node SDK with auto-instrumentation covers HTTP, PostgreSQL, Redis and more. Export via OTLP to a Collector, then to any backend such as Grafana, Jaeger, Honeycomb or Datadog, and track RED metrics (rate, errors, duration) per route.
- SLOs and alerting
- Define service level objectives on user-facing latency and error rate, and alert on error budget burn rather than on every CPU spike. Dashboards answer known questions; traces with high-cardinality attributes answer the unknown ones.
- OWASP API Security Top 10
- The 2023 edition is still the current API list: broken object level authorization (BOLA), broken authentication, broken object property level authorization, unrestricted resource consumption, broken function level authorization, unrestricted access to sensitive business flows, SSRF, misconfiguration, improper inventory management and unsafe consumption of APIs. BOLA tops the list for a reason, so test it on every endpoint.
- Hardening the service
- Enforce body size limits, timeouts and rate limits, block SSRF by allowlisting outbound hosts, and set security headers with Helmet. Scan dependencies and container images in CI, pin lockfiles, and treat npm supply chain attacks as a real risk.