@reqray/fastify 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +13 -2
- package/dist/index.cjs +169 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +38 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +134 -0
- package/dist/index.js.map +1 -0
- package/package.json +71 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ruslan Kryklyvyi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @reqray/fastify
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Fastify adapter for Reqray.
|
|
4
|
+
|
|
5
|
+
Part of [Reqray](https://github.com/reqray/reqray) — a dev panel and request-inspection tool for
|
|
6
|
+
Node.js. It instruments HTTP, SQL, outgoing calls and cache on its own, shows
|
|
7
|
+
every request as a waterfall, and finds N+1 down to the file and the line.
|
|
8
|
+
|
|
9
|
+
Documentation, screenshots and a demo that runs with one command are in the
|
|
10
|
+
[main README](https://github.com/reqray/reqray#readme).
|
|
11
|
+
|
|
12
|
+
## License
|
|
13
|
+
|
|
14
|
+
[MIT](https://github.com/reqray/reqray/blob/main/LICENSE)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
default: () => index_default,
|
|
34
|
+
recordFailure: () => recordFailure,
|
|
35
|
+
reqray: () => reqray
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
|
|
39
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.26_supports-color@7.2.0_typescript@6.0.3_yaml@2.9.0/node_modules/tsup/assets/cjs_shims.js
|
|
40
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
41
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
42
|
+
|
|
43
|
+
// src/index.ts
|
|
44
|
+
var import_node_module = require("module");
|
|
45
|
+
var import_node_path = require("path");
|
|
46
|
+
var import_core = require("@reqray/core");
|
|
47
|
+
var import_panel = require("@reqray/core/panel");
|
|
48
|
+
var import_store_memory = require("@reqray/store-memory");
|
|
49
|
+
var import_fastify_plugin = __toESM(require("fastify-plugin"), 1);
|
|
50
|
+
var states = /* @__PURE__ */ new WeakMap();
|
|
51
|
+
function dashboardAssets() {
|
|
52
|
+
try {
|
|
53
|
+
const manifest = (0, import_node_module.createRequire)(importMetaUrl).resolve("@reqray/dashboard/package.json");
|
|
54
|
+
return (0, import_node_path.join)((0, import_node_path.dirname)(manifest), "dist");
|
|
55
|
+
} catch {
|
|
56
|
+
return void 0;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function headerValue(raw) {
|
|
60
|
+
if (typeof raw === "string") return raw;
|
|
61
|
+
return Array.isArray(raw) ? raw[0] ?? null : null;
|
|
62
|
+
}
|
|
63
|
+
function splitQuery(url) {
|
|
64
|
+
const index = url.indexOf("?");
|
|
65
|
+
return index === -1 ? [url, null] : [url.slice(0, index), url.slice(index + 1)];
|
|
66
|
+
}
|
|
67
|
+
var plugin = (app, init, done) => {
|
|
68
|
+
(0, import_core.markAdapterActive)();
|
|
69
|
+
(0, import_core.reportInstrumentation)({
|
|
70
|
+
name: "fastify",
|
|
71
|
+
version: app.version,
|
|
72
|
+
captures: "requests",
|
|
73
|
+
ok: true
|
|
74
|
+
});
|
|
75
|
+
const runtime = (0, import_core.createReqray)({ ...init, transport: init.transport ?? (0, import_store_memory.memoryTransport)() });
|
|
76
|
+
app.decorate("reqray", runtime);
|
|
77
|
+
if (!runtime.options.enabled) {
|
|
78
|
+
done();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const source = (0, import_panel.panelSourceFor)(runtime.transport, runtime.options);
|
|
82
|
+
const panel = source ? (0, import_panel.createPanelHandler)({ source, options: runtime.options, assetsDir: dashboardAssets() }) : null;
|
|
83
|
+
if (panel) {
|
|
84
|
+
app.addHook("onRequest", (request, reply, next) => {
|
|
85
|
+
if (panel(request.raw, reply.raw)) {
|
|
86
|
+
reply.hijack();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
next();
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
app.addHook("onRequest", (request, reply, next) => {
|
|
93
|
+
const [path, query] = splitQuery(request.url);
|
|
94
|
+
const scope = runtime.begin({
|
|
95
|
+
method: request.method,
|
|
96
|
+
path,
|
|
97
|
+
replayId: headerValue(request.headers[import_core.REPLAY_HEADER])
|
|
98
|
+
});
|
|
99
|
+
if (!scope) {
|
|
100
|
+
next();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
(0, import_core.enterScope)(scope);
|
|
104
|
+
states.set(request, {
|
|
105
|
+
scope,
|
|
106
|
+
reply,
|
|
107
|
+
handlerSpan: scope.openSpan("handler", `${request.method} ${path}`),
|
|
108
|
+
query,
|
|
109
|
+
responseBody: void 0,
|
|
110
|
+
failure: void 0
|
|
111
|
+
});
|
|
112
|
+
next();
|
|
113
|
+
});
|
|
114
|
+
app.addHook("onSend", (request, _reply, payload, next) => {
|
|
115
|
+
const state = states.get(request);
|
|
116
|
+
if (state) state.responseBody = payload;
|
|
117
|
+
next(null, payload);
|
|
118
|
+
});
|
|
119
|
+
app.addHook("onError", (request, _reply, error, next) => {
|
|
120
|
+
const state = states.get(request);
|
|
121
|
+
if (state) state.failure = error;
|
|
122
|
+
next();
|
|
123
|
+
});
|
|
124
|
+
const complete = (request) => {
|
|
125
|
+
const state = states.get(request);
|
|
126
|
+
if (!state) return;
|
|
127
|
+
states.delete(request);
|
|
128
|
+
const reply = state.reply;
|
|
129
|
+
try {
|
|
130
|
+
state.scope.closeSpan(state.handlerSpan);
|
|
131
|
+
runtime.finish(state.scope, {
|
|
132
|
+
status: reply.statusCode,
|
|
133
|
+
query: state.query,
|
|
134
|
+
requestHeaders: request.headers,
|
|
135
|
+
responseHeaders: reply.getHeaders(),
|
|
136
|
+
requestBody: request.body,
|
|
137
|
+
responseBody: state.responseBody,
|
|
138
|
+
error: state.failure
|
|
139
|
+
});
|
|
140
|
+
} catch (error) {
|
|
141
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
142
|
+
(0, import_core.warnOnce)("fastify.finish", `request not recorded: ${reason}`);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
app.addHook("onResponse", (request, _reply, next) => {
|
|
146
|
+
complete(request);
|
|
147
|
+
next();
|
|
148
|
+
});
|
|
149
|
+
app.addHook("onRequestAbort", (request, next) => {
|
|
150
|
+
complete(request);
|
|
151
|
+
next();
|
|
152
|
+
});
|
|
153
|
+
done();
|
|
154
|
+
};
|
|
155
|
+
function recordFailure(request, error) {
|
|
156
|
+
const state = states.get(request);
|
|
157
|
+
if (state) state.failure = error;
|
|
158
|
+
}
|
|
159
|
+
var reqray = (0, import_fastify_plugin.default)(plugin, {
|
|
160
|
+
fastify: "5.x",
|
|
161
|
+
name: "@reqray/fastify"
|
|
162
|
+
});
|
|
163
|
+
var index_default = reqray;
|
|
164
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
165
|
+
0 && (module.exports = {
|
|
166
|
+
recordFailure,
|
|
167
|
+
reqray
|
|
168
|
+
});
|
|
169
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../../../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.26_supports-color@7.2.0_typescript@6.0.3_yaml@2.9.0/node_modules/tsup/assets/cjs_shims.js"],"sourcesContent":["/**\n * `@reqray/fastify` — Fastify adapter.\n *\n * Built on the regular hooks: that is the official extension point with a\n * stable contract, so nothing has to be patched. The start and the end of a\n * request are different hooks, so the context is entered via `enterScope`\n * instead of by wrapping a function.\n */\n\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport {\n createReqray,\n enterScope,\n markAdapterActive,\n REPLAY_HEADER,\n type Reqray,\n type ReqrayInit,\n type RequestScope,\n reportInstrumentation,\n warnOnce,\n} from '@reqray/core';\nimport { createPanelHandler, panelSourceFor } from '@reqray/core/panel';\nimport { memoryTransport } from '@reqray/store-memory';\nimport type { FastifyInstance, FastifyPluginCallback, FastifyReply, FastifyRequest } from 'fastify';\nimport fp from 'fastify-plugin';\n\ndeclare module 'fastify' {\n interface FastifyInstance {\n /** Reqray runtime: transport and options. */\n readonly reqray: Reqray;\n }\n}\n\n/** State that lives from `onRequest` through to `onResponse`. */\ninterface RequestState {\n readonly scope: RequestScope;\n /** Kept because `onRequestAbort` is handed the request alone. */\n readonly reply: FastifyReply;\n readonly handlerSpan: number;\n readonly query: string | null;\n responseBody: unknown;\n failure: unknown;\n}\n\n// A WeakMap rather than decorating the request: the shape of somebody else's\n// object stays untouched and nothing is left behind.\nconst states = new WeakMap<FastifyRequest, RequestState>();\n\n/**\n * Directory with the built dashboard.\n *\n * Resolved optionally: without `@reqray/dashboard` installed the API still\n * works, only the UI route reports that the panel is incomplete.\n */\nfunction dashboardAssets(): string | undefined {\n try {\n const manifest = createRequire(import.meta.url).resolve('@reqray/dashboard/package.json');\n return join(dirname(manifest), 'dist');\n } catch {\n return undefined;\n }\n}\n\nfunction headerValue(raw: string | string[] | undefined): string | null {\n if (typeof raw === 'string') return raw;\n return Array.isArray(raw) ? (raw[0] ?? null) : null;\n}\n\nfunction splitQuery(url: string): [path: string, query: string | null] {\n const index = url.indexOf('?');\n return index === -1 ? [url, null] : [url.slice(0, index), url.slice(index + 1)];\n}\n\nconst plugin: FastifyPluginCallback<ReqrayInit> = (app: FastifyInstance, init, done) => {\n // The standalone mode in @reqray/register stands down once an adapter exists.\n markAdapterActive();\n reportInstrumentation({\n name: 'fastify',\n version: app.version,\n captures: 'requests',\n ok: true,\n });\n\n const runtime = createReqray({ ...init, transport: init.transport ?? memoryTransport() });\n app.decorate('reqray', runtime);\n\n // A disabled Reqray costs nothing per request, and the only way to mean that\n // literally is to register no hooks at all. Checking `enabled` inside a hook\n // would still allocate the argument object it is checked from.\n if (!runtime.options.enabled) {\n done();\n return;\n }\n\n const source = panelSourceFor(runtime.transport, runtime.options);\n const panel = source\n ? createPanelHandler({ source, options: runtime.options, assetsDir: dashboardAssets() })\n : null;\n\n if (panel) {\n // The panel hook is registered first: its own requests must not end up in\n // the list it displays.\n app.addHook('onRequest', (request, reply, next) => {\n if (panel(request.raw, reply.raw)) {\n // The response is already written straight to the socket — Fastify has\n // nothing left to do here.\n reply.hijack();\n return;\n }\n next();\n });\n }\n\n app.addHook('onRequest', (request, reply, next) => {\n const [path, query] = splitQuery(request.url);\n const scope = runtime.begin({\n method: request.method,\n path,\n replayId: headerValue(request.headers[REPLAY_HEADER]),\n });\n // Reqray is disabled — no allocations, no state kept.\n if (!scope) {\n next();\n return;\n }\n\n // `enterWith` inside the hook: the rest of the handling is a child of this\n // async resource, so the scope is visible to every later hook and to the\n // handler itself.\n enterScope(scope);\n\n states.set(request, {\n scope,\n reply,\n handlerSpan: scope.openSpan('handler', `${request.method} ${path}`),\n query,\n responseBody: undefined,\n failure: undefined,\n });\n next();\n });\n\n app.addHook('onSend', (request, _reply, payload, next) => {\n const state = states.get(request);\n // The body is stored as-is; parsing and masking happen at finalization.\n if (state) state.responseBody = payload;\n next(null, payload);\n });\n\n app.addHook('onError', (request, _reply, error, next) => {\n const state = states.get(request);\n if (state) state.failure = error;\n // The error is left alone: Fastify handles it as usual.\n next();\n });\n\n // Called from whichever hook ends the request, and once: the state is\n // taken out of the map on the way in.\n const complete = (request: FastifyRequest): void => {\n const state = states.get(request);\n if (!state) return;\n states.delete(request);\n const reply = state.reply;\n\n try {\n state.scope.closeSpan(state.handlerSpan);\n runtime.finish(state.scope, {\n status: reply.statusCode,\n query: state.query,\n requestHeaders: request.headers,\n responseHeaders: reply.getHeaders(),\n requestBody: request.body,\n responseBody: state.responseBody,\n error: state.failure,\n });\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n warnOnce('fastify.finish', `request not recorded: ${reason}`);\n }\n };\n\n app.addHook('onResponse', (request: FastifyRequest, _reply: FastifyReply, next) => {\n complete(request);\n next();\n });\n\n // A client that gave up gets no response, so `onResponse` never fires — and\n // the request it gave up on is the slow one, the one worth seeing.\n app.addHook('onRequestAbort', (request: FastifyRequest, next) => {\n complete(request);\n next();\n });\n\n done();\n};\n\n/**\n * Stamps the exception onto the request the way the `onError` hook does.\n *\n * For frameworks on top of Fastify (NestJS) that intercept exceptions before\n * Fastify's own error handling, so `onError` never fires. Safe to call with\n * anything — an unknown request is simply ignored.\n */\nexport function recordFailure(request: unknown, error: unknown): void {\n const state = states.get(request as FastifyRequest);\n if (state) state.failure = error;\n}\n\n/**\n * Reqray plugin for Fastify.\n *\n * @example\n * ```ts\n * await app.register(reqray);\n * // app.reqray — the runtime: transport, options\n * ```\n */\nexport const reqray = fp(plugin, {\n fastify: '5.x',\n name: '@reqray/fastify',\n});\n\nexport default reqray;\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,QAAQ,YAAY,MAAM,WAC1E,SAAS,cAAc,MACvB,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEtC,IAAM,gBAAgC,iCAAiB;;;ADH9D,yBAA8B;AAC9B,uBAA8B;AAC9B,kBAUO;AACP,mBAAmD;AACnD,0BAAgC;AAEhC,4BAAe;AAsBf,IAAM,SAAS,oBAAI,QAAsC;AAQzD,SAAS,kBAAsC;AAC7C,MAAI;AACF,UAAM,eAAW,kCAAc,aAAe,EAAE,QAAQ,gCAAgC;AACxF,eAAO,2BAAK,0BAAQ,QAAQ,GAAG,MAAM;AAAA,EACvC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,YAAY,KAAmD;AACtE,MAAI,OAAO,QAAQ,SAAU,QAAO;AACpC,SAAO,MAAM,QAAQ,GAAG,IAAK,IAAI,CAAC,KAAK,OAAQ;AAC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AA,EACP,CAAC;AAED,OAAK;AACP;AASO,SAAS,cAAc,SAAkB,OAAsB;AACpE,QAAM,QAAQ,OAAO,IAAI,OAAyB;AAClD,MAAI,MAAO,OAAM,UAAU;AAC7B;AAWO,IAAM,aAAS,sBAAAA,SAAG,QAAQ;AAAA,EAC/B,SAAS;AAAA,EACT,MAAM;AACR,CAAC;AAED,IAAO,gBAAQ;","names":["fp"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Reqray, ReqrayInit } from '@reqray/core';
|
|
2
|
+
import { FastifyPluginCallback } from 'fastify';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `@reqray/fastify` — Fastify adapter.
|
|
6
|
+
*
|
|
7
|
+
* Built on the regular hooks: that is the official extension point with a
|
|
8
|
+
* stable contract, so nothing has to be patched. The start and the end of a
|
|
9
|
+
* request are different hooks, so the context is entered via `enterScope`
|
|
10
|
+
* instead of by wrapping a function.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
declare module 'fastify' {
|
|
14
|
+
interface FastifyInstance {
|
|
15
|
+
/** Reqray runtime: transport and options. */
|
|
16
|
+
readonly reqray: Reqray;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Stamps the exception onto the request the way the `onError` hook does.
|
|
21
|
+
*
|
|
22
|
+
* For frameworks on top of Fastify (NestJS) that intercept exceptions before
|
|
23
|
+
* Fastify's own error handling, so `onError` never fires. Safe to call with
|
|
24
|
+
* anything — an unknown request is simply ignored.
|
|
25
|
+
*/
|
|
26
|
+
declare function recordFailure(request: unknown, error: unknown): void;
|
|
27
|
+
/**
|
|
28
|
+
* Reqray plugin for Fastify.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* await app.register(reqray);
|
|
33
|
+
* // app.reqray — the runtime: transport, options
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare const reqray: FastifyPluginCallback<ReqrayInit>;
|
|
37
|
+
|
|
38
|
+
export { reqray as default, recordFailure, reqray };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Reqray, ReqrayInit } from '@reqray/core';
|
|
2
|
+
import { FastifyPluginCallback } from 'fastify';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `@reqray/fastify` — Fastify adapter.
|
|
6
|
+
*
|
|
7
|
+
* Built on the regular hooks: that is the official extension point with a
|
|
8
|
+
* stable contract, so nothing has to be patched. The start and the end of a
|
|
9
|
+
* request are different hooks, so the context is entered via `enterScope`
|
|
10
|
+
* instead of by wrapping a function.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
declare module 'fastify' {
|
|
14
|
+
interface FastifyInstance {
|
|
15
|
+
/** Reqray runtime: transport and options. */
|
|
16
|
+
readonly reqray: Reqray;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Stamps the exception onto the request the way the `onError` hook does.
|
|
21
|
+
*
|
|
22
|
+
* For frameworks on top of Fastify (NestJS) that intercept exceptions before
|
|
23
|
+
* Fastify's own error handling, so `onError` never fires. Safe to call with
|
|
24
|
+
* anything — an unknown request is simply ignored.
|
|
25
|
+
*/
|
|
26
|
+
declare function recordFailure(request: unknown, error: unknown): void;
|
|
27
|
+
/**
|
|
28
|
+
* Reqray plugin for Fastify.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* await app.register(reqray);
|
|
33
|
+
* // app.reqray — the runtime: transport, options
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare const reqray: FastifyPluginCallback<ReqrayInit>;
|
|
37
|
+
|
|
38
|
+
export { reqray as default, recordFailure, reqray };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
import { dirname, join } from "path";
|
|
4
|
+
import {
|
|
5
|
+
createReqray,
|
|
6
|
+
enterScope,
|
|
7
|
+
markAdapterActive,
|
|
8
|
+
REPLAY_HEADER,
|
|
9
|
+
reportInstrumentation,
|
|
10
|
+
warnOnce
|
|
11
|
+
} from "@reqray/core";
|
|
12
|
+
import { createPanelHandler, panelSourceFor } from "@reqray/core/panel";
|
|
13
|
+
import { memoryTransport } from "@reqray/store-memory";
|
|
14
|
+
import fp from "fastify-plugin";
|
|
15
|
+
var states = /* @__PURE__ */ new WeakMap();
|
|
16
|
+
function dashboardAssets() {
|
|
17
|
+
try {
|
|
18
|
+
const manifest = createRequire(import.meta.url).resolve("@reqray/dashboard/package.json");
|
|
19
|
+
return join(dirname(manifest), "dist");
|
|
20
|
+
} catch {
|
|
21
|
+
return void 0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function headerValue(raw) {
|
|
25
|
+
if (typeof raw === "string") return raw;
|
|
26
|
+
return Array.isArray(raw) ? raw[0] ?? null : null;
|
|
27
|
+
}
|
|
28
|
+
function splitQuery(url) {
|
|
29
|
+
const index = url.indexOf("?");
|
|
30
|
+
return index === -1 ? [url, null] : [url.slice(0, index), url.slice(index + 1)];
|
|
31
|
+
}
|
|
32
|
+
var plugin = (app, init, done) => {
|
|
33
|
+
markAdapterActive();
|
|
34
|
+
reportInstrumentation({
|
|
35
|
+
name: "fastify",
|
|
36
|
+
version: app.version,
|
|
37
|
+
captures: "requests",
|
|
38
|
+
ok: true
|
|
39
|
+
});
|
|
40
|
+
const runtime = createReqray({ ...init, transport: init.transport ?? memoryTransport() });
|
|
41
|
+
app.decorate("reqray", runtime);
|
|
42
|
+
if (!runtime.options.enabled) {
|
|
43
|
+
done();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const source = panelSourceFor(runtime.transport, runtime.options);
|
|
47
|
+
const panel = source ? createPanelHandler({ source, options: runtime.options, assetsDir: dashboardAssets() }) : null;
|
|
48
|
+
if (panel) {
|
|
49
|
+
app.addHook("onRequest", (request, reply, next) => {
|
|
50
|
+
if (panel(request.raw, reply.raw)) {
|
|
51
|
+
reply.hijack();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
next();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
app.addHook("onRequest", (request, reply, next) => {
|
|
58
|
+
const [path, query] = splitQuery(request.url);
|
|
59
|
+
const scope = runtime.begin({
|
|
60
|
+
method: request.method,
|
|
61
|
+
path,
|
|
62
|
+
replayId: headerValue(request.headers[REPLAY_HEADER])
|
|
63
|
+
});
|
|
64
|
+
if (!scope) {
|
|
65
|
+
next();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
enterScope(scope);
|
|
69
|
+
states.set(request, {
|
|
70
|
+
scope,
|
|
71
|
+
reply,
|
|
72
|
+
handlerSpan: scope.openSpan("handler", `${request.method} ${path}`),
|
|
73
|
+
query,
|
|
74
|
+
responseBody: void 0,
|
|
75
|
+
failure: void 0
|
|
76
|
+
});
|
|
77
|
+
next();
|
|
78
|
+
});
|
|
79
|
+
app.addHook("onSend", (request, _reply, payload, next) => {
|
|
80
|
+
const state = states.get(request);
|
|
81
|
+
if (state) state.responseBody = payload;
|
|
82
|
+
next(null, payload);
|
|
83
|
+
});
|
|
84
|
+
app.addHook("onError", (request, _reply, error, next) => {
|
|
85
|
+
const state = states.get(request);
|
|
86
|
+
if (state) state.failure = error;
|
|
87
|
+
next();
|
|
88
|
+
});
|
|
89
|
+
const complete = (request) => {
|
|
90
|
+
const state = states.get(request);
|
|
91
|
+
if (!state) return;
|
|
92
|
+
states.delete(request);
|
|
93
|
+
const reply = state.reply;
|
|
94
|
+
try {
|
|
95
|
+
state.scope.closeSpan(state.handlerSpan);
|
|
96
|
+
runtime.finish(state.scope, {
|
|
97
|
+
status: reply.statusCode,
|
|
98
|
+
query: state.query,
|
|
99
|
+
requestHeaders: request.headers,
|
|
100
|
+
responseHeaders: reply.getHeaders(),
|
|
101
|
+
requestBody: request.body,
|
|
102
|
+
responseBody: state.responseBody,
|
|
103
|
+
error: state.failure
|
|
104
|
+
});
|
|
105
|
+
} catch (error) {
|
|
106
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
107
|
+
warnOnce("fastify.finish", `request not recorded: ${reason}`);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
app.addHook("onResponse", (request, _reply, next) => {
|
|
111
|
+
complete(request);
|
|
112
|
+
next();
|
|
113
|
+
});
|
|
114
|
+
app.addHook("onRequestAbort", (request, next) => {
|
|
115
|
+
complete(request);
|
|
116
|
+
next();
|
|
117
|
+
});
|
|
118
|
+
done();
|
|
119
|
+
};
|
|
120
|
+
function recordFailure(request, error) {
|
|
121
|
+
const state = states.get(request);
|
|
122
|
+
if (state) state.failure = error;
|
|
123
|
+
}
|
|
124
|
+
var reqray = fp(plugin, {
|
|
125
|
+
fastify: "5.x",
|
|
126
|
+
name: "@reqray/fastify"
|
|
127
|
+
});
|
|
128
|
+
var index_default = reqray;
|
|
129
|
+
export {
|
|
130
|
+
index_default as default,
|
|
131
|
+
recordFailure,
|
|
132
|
+
reqray
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@reqray/fastify` — Fastify adapter.\n *\n * Built on the regular hooks: that is the official extension point with a\n * stable contract, so nothing has to be patched. The start and the end of a\n * request are different hooks, so the context is entered via `enterScope`\n * instead of by wrapping a function.\n */\n\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport {\n createReqray,\n enterScope,\n markAdapterActive,\n REPLAY_HEADER,\n type Reqray,\n type ReqrayInit,\n type RequestScope,\n reportInstrumentation,\n warnOnce,\n} from '@reqray/core';\nimport { createPanelHandler, panelSourceFor } from '@reqray/core/panel';\nimport { memoryTransport } from '@reqray/store-memory';\nimport type { FastifyInstance, FastifyPluginCallback, FastifyReply, FastifyRequest } from 'fastify';\nimport fp from 'fastify-plugin';\n\ndeclare module 'fastify' {\n interface FastifyInstance {\n /** Reqray runtime: transport and options. */\n readonly reqray: Reqray;\n }\n}\n\n/** State that lives from `onRequest` through to `onResponse`. */\ninterface RequestState {\n readonly scope: RequestScope;\n /** Kept because `onRequestAbort` is handed the request alone. */\n readonly reply: FastifyReply;\n readonly handlerSpan: number;\n readonly query: string | null;\n responseBody: unknown;\n failure: unknown;\n}\n\n// A WeakMap rather than decorating the request: the shape of somebody else's\n// object stays untouched and nothing is left behind.\nconst states = new WeakMap<FastifyRequest, RequestState>();\n\n/**\n * Directory with the built dashboard.\n *\n * Resolved optionally: without `@reqray/dashboard` installed the API still\n * works, only the UI route reports that the panel is incomplete.\n */\nfunction dashboardAssets(): string | undefined {\n try {\n const manifest = createRequire(import.meta.url).resolve('@reqray/dashboard/package.json');\n return join(dirname(manifest), 'dist');\n } catch {\n return undefined;\n }\n}\n\nfunction headerValue(raw: string | string[] | undefined): string | null {\n if (typeof raw === 'string') return raw;\n return Array.isArray(raw) ? (raw[0] ?? null) : null;\n}\n\nfunction splitQuery(url: string): [path: string, query: string | null] {\n const index = url.indexOf('?');\n return index === -1 ? [url, null] : [url.slice(0, index), url.slice(index + 1)];\n}\n\nconst plugin: FastifyPluginCallback<ReqrayInit> = (app: FastifyInstance, init, done) => {\n // The standalone mode in @reqray/register stands down once an adapter exists.\n markAdapterActive();\n reportInstrumentation({\n name: 'fastify',\n version: app.version,\n captures: 'requests',\n ok: true,\n });\n\n const runtime = createReqray({ ...init, transport: init.transport ?? memoryTransport() });\n app.decorate('reqray', runtime);\n\n // A disabled Reqray costs nothing per request, and the only way to mean that\n // literally is to register no hooks at all. Checking `enabled` inside a hook\n // would still allocate the argument object it is checked from.\n if (!runtime.options.enabled) {\n done();\n return;\n }\n\n const source = panelSourceFor(runtime.transport, runtime.options);\n const panel = source\n ? createPanelHandler({ source, options: runtime.options, assetsDir: dashboardAssets() })\n : null;\n\n if (panel) {\n // The panel hook is registered first: its own requests must not end up in\n // the list it displays.\n app.addHook('onRequest', (request, reply, next) => {\n if (panel(request.raw, reply.raw)) {\n // The response is already written straight to the socket — Fastify has\n // nothing left to do here.\n reply.hijack();\n return;\n }\n next();\n });\n }\n\n app.addHook('onRequest', (request, reply, next) => {\n const [path, query] = splitQuery(request.url);\n const scope = runtime.begin({\n method: request.method,\n path,\n replayId: headerValue(request.headers[REPLAY_HEADER]),\n });\n // Reqray is disabled — no allocations, no state kept.\n if (!scope) {\n next();\n return;\n }\n\n // `enterWith` inside the hook: the rest of the handling is a child of this\n // async resource, so the scope is visible to every later hook and to the\n // handler itself.\n enterScope(scope);\n\n states.set(request, {\n scope,\n reply,\n handlerSpan: scope.openSpan('handler', `${request.method} ${path}`),\n query,\n responseBody: undefined,\n failure: undefined,\n });\n next();\n });\n\n app.addHook('onSend', (request, _reply, payload, next) => {\n const state = states.get(request);\n // The body is stored as-is; parsing and masking happen at finalization.\n if (state) state.responseBody = payload;\n next(null, payload);\n });\n\n app.addHook('onError', (request, _reply, error, next) => {\n const state = states.get(request);\n if (state) state.failure = error;\n // The error is left alone: Fastify handles it as usual.\n next();\n });\n\n // Called from whichever hook ends the request, and once: the state is\n // taken out of the map on the way in.\n const complete = (request: FastifyRequest): void => {\n const state = states.get(request);\n if (!state) return;\n states.delete(request);\n const reply = state.reply;\n\n try {\n state.scope.closeSpan(state.handlerSpan);\n runtime.finish(state.scope, {\n status: reply.statusCode,\n query: state.query,\n requestHeaders: request.headers,\n responseHeaders: reply.getHeaders(),\n requestBody: request.body,\n responseBody: state.responseBody,\n error: state.failure,\n });\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n warnOnce('fastify.finish', `request not recorded: ${reason}`);\n }\n };\n\n app.addHook('onResponse', (request: FastifyRequest, _reply: FastifyReply, next) => {\n complete(request);\n next();\n });\n\n // A client that gave up gets no response, so `onResponse` never fires — and\n // the request it gave up on is the slow one, the one worth seeing.\n app.addHook('onRequestAbort', (request: FastifyRequest, next) => {\n complete(request);\n next();\n });\n\n done();\n};\n\n/**\n * Stamps the exception onto the request the way the `onError` hook does.\n *\n * For frameworks on top of Fastify (NestJS) that intercept exceptions before\n * Fastify's own error handling, so `onError` never fires. Safe to call with\n * anything — an unknown request is simply ignored.\n */\nexport function recordFailure(request: unknown, error: unknown): void {\n const state = states.get(request as FastifyRequest);\n if (state) state.failure = error;\n}\n\n/**\n * Reqray plugin for Fastify.\n *\n * @example\n * ```ts\n * await app.register(reqray);\n * // app.reqray — the runtime: transport, options\n * ```\n */\nexport const reqray = fp(plugin, {\n fastify: '5.x',\n name: '@reqray/fastify',\n});\n\nexport default reqray;\n"],"mappings":";AASA,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB,sBAAsB;AACnD,SAAS,uBAAuB;AAEhC,OAAO,QAAQ;AAsBf,IAAM,SAAS,oBAAI,QAAsC;AAQzD,SAAS,kBAAsC;AAC7C,MAAI;AACF,UAAM,WAAW,cAAc,YAAY,GAAG,EAAE,QAAQ,gCAAgC;AACxF,WAAO,KAAK,QAAQ,QAAQ,GAAG,MAAM;AAAA,EACvC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,YAAY,KAAmD;AACtE,MAAI,OAAO,QAAQ,SAAU,QAAO;AACpC,SAAO,MAAM,QAAQ,GAAG,IAAK,IAAI,CAAC,KAAK,OAAQ;AACjD;AAEA,SAAS,WAAW,KAAmD;AACrE,QAAM,QAAQ,IAAI,QAAQ,GAAG;AAC7B,SAAO,UAAU,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,MAAM,GAAG,KAAK,GAAG,IAAI,MAAM,QAAQ,CAAC,CAAC;AAChF;AAEA,IAAM,SAA4C,CAAC,KAAsB,MAAM,SAAS;AAEtF,oBAAkB;AAClB,wBAAsB;AAAA,IACpB,MA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|
1
1
|
{
|
|
2
2
|
"name": "@reqray/fastify",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Fastify adapter for Reqray.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"nodejs",
|
|
8
|
+
"debugging",
|
|
9
|
+
"profiling",
|
|
10
|
+
"n+1",
|
|
11
|
+
"sql",
|
|
12
|
+
"observability",
|
|
13
|
+
"devtools",
|
|
14
|
+
"fastify",
|
|
15
|
+
"express",
|
|
16
|
+
"nestjs"
|
|
17
|
+
],
|
|
18
|
+
"homepage": "https://github.com/reqray/reqray#readme",
|
|
19
|
+
"bugs": "https://github.com/reqray/reqray/issues",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/reqray/reqray.git",
|
|
23
|
+
"directory": "packages/fastify"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=20"
|
|
28
|
+
},
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"import": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./dist/index.d.cts",
|
|
37
|
+
"default": "./dist/index.cjs"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"main": "./dist/index.cjs",
|
|
42
|
+
"module": "./dist/index.js",
|
|
43
|
+
"types": "./dist/index.d.ts",
|
|
44
|
+
"files": [
|
|
45
|
+
"dist"
|
|
46
|
+
],
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"fastify-plugin": "^6.0.0",
|
|
52
|
+
"@reqray/core": "^0.1.0",
|
|
53
|
+
"@reqray/store-memory": "^0.1.0",
|
|
54
|
+
"@reqray/dashboard": "^0.1.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"fastify": "^5"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/node": "^26.2.0",
|
|
61
|
+
"tsup": "^8.5.1",
|
|
62
|
+
"typescript": "^6.0.3",
|
|
63
|
+
"fastify": "^5.12.0"
|
|
64
|
+
},
|
|
65
|
+
"peerDependenciesMeta": {
|
|
66
|
+
"fastify": {
|
|
67
|
+
"optional": true
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"scripts": {
|
|
71
|
+
"build": "tsup",
|
|
72
|
+
"typecheck": "tsc --noEmit"
|
|
73
|
+
}
|
|
6
74
|
}
|