@reqray/fastify
v0.1.1
Published
Reqray for Fastify: every request as a waterfall with its SQL, cache and outgoing calls, and N+1 queries found down to the line.
Downloads
585
Maintainers
Readme
@reqray/fastify
Reqray for Fastify: every request as a waterfall — SQL, outgoing HTTP, cache, bodies after masking — and N+1 queries pointed at the file and the line.

Use
npm install @reqray/fastify @reqray/registerimport Fastify from 'fastify';
import { reqray } from '@reqray/fastify';
const app = Fastify();
await app.register(reqray);node --import @reqray/register app.js
# open http://localhost:3000/_reqray/--import @reqray/register is what instruments the database driver, the cache
client and fetch; without it the plugin records requests and nothing inside
them, and says so at startup.
Fastify 5. Node 20 or newer.
Options
await app.register(reqray, {
panel: { gate: ({ headers }) => headers['x-admin'] === process.env.ADMIN_KEY },
redact: { headers: ['x-api-key'] },
detect: { nPlusOne: { threshold: 10 } },
});| Option | Default | What it does |
|---|---|---|
| enabled | NODE_ENV !== 'production' | Off means off: nothing is recorded and nothing is mounted |
| mode | from NODE_ENV | 'development' keeps every request; 'production' samples |
| panel | { path: '/_reqray' } | false to not mount it; { gate } decides who gets in |
| transport | memory, last 500 requests | Where records go — see @reqray/store-sqlite, @reqray/transport-http, @reqray/transport-file |
| redact | see below | { headers: [...], body: [...] } extend the masked names |
| detect | all on | { nPlusOne: { threshold: 10 }, slowBudget: false } |
| sampling | 100% locally, 1% in production | { rate, slowMs, alwaysOnError, alwaysOnFinding } |
| replay, explain, blame | local development only | Opt-in anywhere else |
| collectSqlValues | false | SQL parameter values are never recorded unless you ask |
Masked before anything is stored: authorization, cookie, set-cookie in
headers; password, token, secret, cardNumber, cvv, apiKey,
signature in bodies and query strings.
Outside local development the panel does not mount without an explicit gate —
the application fails at startup with an explanation rather than opening
access. panel: { gate: 'open' } if open is what you mean, or a function:
gate: ({ headers, ip }) => headers['x-admin'] === process.env.ADMIN_KEY.
Exceptions
An exception thrown by a handler lands in the request's record through
Fastify's onError hook. A framework on top of Fastify that catches
exceptions first can hand them over with recordFailure(request, error).
More
Everything else — the detectors, security defaults, measured overhead and a demo that runs with one command — is in the main README.
