← ClaudeAtlas

mir-backend-node-fastifylisted

Make It Right (Fastify module). Fastify 4/5 + Node.js specific reliability augmentation. Use alongside mir-backend and mir-backend-node when the target stack is Fastify — it carries the mechanical footguns that the framework-agnostic tiers deliberately omit: schema-first validation and response serialization (and the data-leak risk of skipping it), the reply lifecycle and double-send traps, plugin encapsulation and decorator scoping, and hook-ordering for authentication. TRIGGER only when the Node backend stack is Fastify — building, reviewing, or debugging a Fastify route, plugin, hook, or schema. Always loads TOGETHER WITH mir-backend (the gates) and mir-backend-node (V8 event-loop / process-model concerns: blocking, worker_threads, unhandled rejections, backpressure, timeouts); this module only adds Fastify library mechanics. SKIP for Express, NestJS, Hapi, Koa, or any non-Fastify stack (those get their own mir-backend-node-<framework> module), and for non-Node runtimes.
anantbhandarkar/make-it-right · ★ 12 · API & Backend · score 83
Install: claude install-skill anantbhandarkar/make-it-right
# /mir-backend-node-fastify · Make It Right (Fastify) Bottom tier of the chain: `mir-backend` (generic gates) → `mir-backend-node` (V8/Node event-loop model) → **this** (Fastify library mechanics). Run the gates first; load the Node runtime tier for event-loop and process-model concerns; reach for *this* at Gate 5 (design mechanics), Gate 6 (implementation), and Gate 7 review. **Runtime-level concerns (blocking the event loop, worker_threads, unhandled rejections, stream backpressure, AbortController timeouts, heap limits) live in `mir-backend-node` — not here.** **Stack assumed:** Fastify 4.x (or 5.x; breaking changes called out) on Node 20+ LTS. ## The Fastify footguns AI walks into most ### 1. Skipping the response schema leaks internal fields Fastify's JSON serialization is powered by `fast-json-stringify`, driven by the JSON Schema on the route. The response schema does two things: it makes serialization 2–5× faster than `JSON.stringify`, **and it strips any field not declared in the schema**. Omitting it hands the full internal object to the client: ```js // WRONG — no response schema; entire DB row (including passwordHash, internalFlags) goes to client fastify.get('/users/:id', async (request, reply) => { return db.findUser(request.params.id); }); // RIGHT — response schema is the serialization + security boundary fastify.get('/users/:id', { schema: { params: { type: 'object', properties: { id: { type: 'string', format: 'uuid' } }, required: ['id'] },