Posts tagged “Fastify”
Node.js large file upload handling without running out of memory
One 2 GB upload should not take your API down with it. Here is how to stream uploads in Express and Fastify, when to use presigned URLs, and which parsers to patch.
Cursor vs offset pagination: an API design that survives big tables and scrapers
Offset pagination was fast at launch; now deep pages hammer the database and one API key is walking every page. Here is when to switch to cursors and how.
Zod validation in Express and Fastify: request bodies, query strings and useful errors
A null where your handler expected an array becomes a 500 and a support ticket. Validate bodies, query strings and params with Zod 4 in Express 5 and Fastify 5, return 400s clients can act on, and stop extra fields at the door.
CORS misconfiguration in Express and Fastify: how to find it and test for it
One line added to silence a frontend error, cors({ origin: true, credentials: true }), lets any website read your users' data. Find CORS misconfiguration in Express and Fastify APIs, fix it, and test it in CI.
Fastify hooks for logging and auth: onRequest, preHandler and onResponse explained
Auth checks that run before the body exists, log lines missing the status code, handlers that run after a 401: most come from using the wrong Fastify hook. Here is which hook does which job in Fastify v5, with working code.
BOLA vulnerability in Node APIs: how to fix IDOR and catch it in your logs
Change one digit in a URL and get another customer's invoice. Here is how to fix BOLA and IDOR structurally and spot someone probing for it before they find a gap.
Node.js fetch timeout: deadlines with AbortSignal and undici
One slow vendor and every handler hangs, because Node fetch waits up to five minutes by default. Here is how to set deadlines with AbortSignal and undici in Express and Fastify.
Node.js health checks that tell the truth: liveness vs readiness
A database blip should not restart every replica of your API. Split /health into liveness and readiness, with Express and Fastify code you can ship today.
Node.js graceful shutdown: stop dropping requests on every deploy
A burst of 502s on every deploy is usually the old process dying with requests in flight. Here is the shutdown order and Express and Fastify code that fixes it in an afternoon.
AsyncLocalStorage request IDs: follow one request through a Node.js API
A customer says checkout failed at 2pm and your logs are fifty requests interleaved. Add request IDs with AsyncLocalStorage in Express or Fastify in an afternoon, and every log line, response and downstream call carries the same ID.
Pino logging in Node.js: a practical structured logging setup for Express and Fastify
A customer says invoices failed yesterday and your logs are a wall of console.log. Set up Pino logging for Express or Fastify in an afternoon: JSON lines, request IDs, levels by status, redaction and a team checklist.