The things every feature needs and no feature owns.

~5,600 words across 7 notes. Built August 2026 — this section was a map pointing elsewhere until then, and one row of that map said “file uploads — not covered anywhere yet — a genuine gap.” That’s note 07.

The one idea: each of these is needed by every feature, which means each should be solved once, centrally, and applied by convention. When the same try/catch or the same permission check is pasted into twenty handlers, a cross-cutting concern has escaped into feature code — and that’s what middleware, filters and interceptors exist to prevent.

Reading order

  1. Validation and DTOs — [Intermediate] — parse, don’t validate, why the boundary is the only place, and what a DTO actually protects you from
  2. Configuration and Secrets — [Intermediate] — layering, validating config at startup, why secrets differ from config, and feature flags that never die
  3. Error Handling — [Intermediate] — one handler at the edge, ProblemDetails, the status-code map, and the line between what the client sees and what you log
  4. Rate Limiting — [Intermediate] — the four algorithms, what to key on, and why in-process limiting silently doesn’t work
  5. Idempotency and Retries — [Intermediate] — a timeout doesn’t tell you whether it happened, idempotency keys, backoff with jitter, circuit breakers
  6. Security Headers and CORS — [Intermediate] — the nearly-free headers, CSP properly, and what CORS actually protects (not your server)
  7. File Uploads — [Intermediate] — presigned URLs, magic-byte validation, decompression bombs, and the checklist

The things worth carrying

  1. After your check, can a downstream function still receive bad data? If yes, you validated rather than parsed → 01
  2. Returning your database entity directly is how passwordHash reaches a client → 01
  3. Validate all config at startup. A container that refuses to boot beats one that fails at 3 a.m. → 02
  4. A leaked secret is not fixed by deleting the commit. Rotate first → 02
  5. 401 means “I don’t know who you are”; 403 means “I know, and no.” And 403 on a resource that exists confirms it exists → 03
  6. Log the exception object, not ex.Message → 03
  7. In-process rate limiting multiplies your limit by your instance count → 04
  8. Behind a proxy you rate-limit your own load balancer unless forwarded headers are configured → 04
  9. Three outcomes, not two: succeeded, failed, and unknown → 05
  10. Retry at one layer. Three layers × 3 retries is 27 requests to a struggling database → 05
  11. Jitter, or an outage recovery becomes a retry storm → 05
  12. CORS protects your users’ other tabs, not your server. A CORS error means the request probably ran → 06
  13. Extension and Content-Type are client-supplied text. Check magic bytes → 07

Still covered elsewhere, deliberately

Not everything cross-cutting belongs here — some of it has a better home and this section links rather than duplicates:

ConcernWhere
Cachingcaching — strategies, stampede, penetration
Logging & observabilityobservability · what to log
Background jobsmessaging & async
Auth itself05-auth — flows, authorization, OAuth
Secret storagesecret management

Per language

These notes are stack-agnostic on purpose. For the implementations side by side — rate limiting, auth, headers, graceful shutdown in six stacks — see cross-language recipes.

↑ Back to Backend