fastify-js
Installation
SKILL.md
Fastify 5
Apply these conventions when working with Fastify code in node.js projects.
Server Setup
- Fastify 5 targets Node.js 20+. Do not write guidance that assumes Node 18 compatibility for new Fastify 5 apps.
- Current Fastify 5 stable is 5.12.1; keep production apps on at least 5.12.1 for the August 2026 security fixes.
- Create the Fastify instance with explicit options:
logger: true(or Pino config object),loggerInstancefor an existing Pino-compatible logger,trustProxywhen behind a reverse proxy. - Set
requestTimeoutwhen exposed without a reverse proxy; usehandlerTimeoutfor application-level route lifecycle timeouts and passrequest.signalinto cancellable work. - For custom request-log behavior or request-id log labels, prefer
logController: new LogController(...); top-leveldisableRequestLoggingandrequestIdLogLabelare deprecated for removal in Fastify 6. - Do not rely on semicolon query delimiters; Fastify 5 defaults
routerOptions.useSemicolonDelimitertofalse. Enable it only for legacy clients that send/path;foo=bar. - Treat forwarded
request.ip/request.host/request.protocolas untrusted unlesstrustProxyis restricted to the real proxy chain; avoid hop-count-only custom trust functions. - Separate app construction (
app.ts) from server startup (server.ts/cluster.ts) to enable testing viainject()without starting the server.