@reqray/express 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +72 -5
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -1,12 +1,79 @@
1
1
  # @reqray/express
2
2
 
3
- Express adapter for Reqray.
3
+ Reqray for Express: every request as a waterfall — SQL, outgoing HTTP, cache,
4
+ bodies after masking — and N+1 queries pointed at the file and the line.
4
5
 
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.
6
+ ![A request arrives, is flagged N+1, and one click shows the line and the fix](https://raw.githubusercontent.com/reqray/reqray/main/docs/screenshots/00-demo.gif)
8
7
 
9
- Documentation, screenshots and a demo that runs with one command are in the
8
+ ## Use
9
+
10
+ ```bash
11
+ npm install @reqray/express @reqray/register
12
+ ```
13
+
14
+ ```js
15
+ import express from 'express';
16
+ import { reqray } from '@reqray/express';
17
+
18
+ const app = express();
19
+ const inspector = reqray();
20
+
21
+ app.use(inspector.middleware); // before the routes
22
+ // ...routes...
23
+ app.use(inspector.errorHandler); // after the routes
24
+ ```
25
+
26
+ ```bash
27
+ node --import @reqray/register app.js
28
+ # open http://localhost:3000/_reqray/
29
+ ```
30
+
31
+ Two handlers, because Express hands an exception only to an error-handling
32
+ middleware installed after the routes. `errorHandler` is optional: without it
33
+ a failed request is still recorded with its status, just without the exception
34
+ itself.
35
+
36
+ `--import @reqray/register` is what instruments the database driver, the cache
37
+ client and `fetch`. A CommonJS application can `require('@reqray/express')` and
38
+ start with `node --require @reqray/register app.js`.
39
+
40
+ Express 4 and 5. Node 20 or newer.
41
+
42
+ ## Options
43
+
44
+ ```js
45
+ const inspector = reqray({
46
+ panel: { gate: ({ headers }) => headers['x-admin'] === process.env.ADMIN_KEY },
47
+ redact: { headers: ['x-api-key'] },
48
+ detect: { nPlusOne: { threshold: 10 } },
49
+ });
50
+ ```
51
+
52
+ | Option | Default | What it does |
53
+ |---|---|---|
54
+ | `enabled` | `NODE_ENV !== 'production'` | Off means off: nothing is recorded and nothing is mounted |
55
+ | `mode` | from `NODE_ENV` | `'development'` keeps every request; `'production'` samples |
56
+ | `panel` | `{ path: '/_reqray' }` | `false` to not mount it; `{ gate }` decides who gets in |
57
+ | `transport` | memory, last 500 requests | Where records go — see `@reqray/store-sqlite`, `@reqray/transport-http`, `@reqray/transport-file` |
58
+ | `redact` | see below | `{ headers: [...], body: [...] }` extend the masked names |
59
+ | `detect` | all on | `{ nPlusOne: { threshold: 10 }, slowBudget: false }` |
60
+ | `sampling` | 100% locally, 1% in production | `{ rate, slowMs, alwaysOnError, alwaysOnFinding }` |
61
+ | `replay`, `explain`, `blame` | local development only | Opt-in anywhere else |
62
+ | `collectSqlValues` | `false` | SQL parameter values are never recorded unless you ask |
63
+
64
+ Masked before anything is stored: `authorization`, `cookie`, `set-cookie` in
65
+ headers; `password`, `token`, `secret`, `cardNumber`, `cvv`, `apiKey`,
66
+ `signature` in bodies and query strings.
67
+
68
+ Outside local development the panel does not mount without an explicit gate —
69
+ the application fails at startup with an explanation rather than opening
70
+ access. `panel: { gate: 'open' }` if open is what you mean, or a function:
71
+ `gate: ({ headers, ip }) => headers['x-admin'] === process.env.ADMIN_KEY`.
72
+
73
+ ## More
74
+
75
+ Everything else — the detectors, security defaults, measured overhead and a
76
+ demo that runs with one command — is in the
10
77
  [main README](https://github.com/reqray/reqray#readme).
11
78
 
12
79
  ## License
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reqray/express",
3
- "version": "0.1.0",
4
- "description": "Express adapter for Reqray.",
3
+ "version": "0.1.1",
4
+ "description": "Reqray for Express: every request as a waterfall with its SQL, cache and outgoing calls, and N+1 queries found down to the line.",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "nodejs",
@@ -48,9 +48,9 @@
48
48
  "access": "public"
49
49
  },
50
50
  "dependencies": {
51
- "@reqray/core": "^0.1.0",
52
- "@reqray/dashboard": "^0.1.0",
53
- "@reqray/store-memory": "^0.1.0"
51
+ "@reqray/core": "^0.1.1",
52
+ "@reqray/store-memory": "^0.1.1",
53
+ "@reqray/dashboard": "^0.1.1"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "express": "^4 || ^5"