@reqray/nestjs 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.
- package/README.md +69 -5
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,12 +1,76 @@
|
|
|
1
1
|
# @reqray/nestjs
|
|
2
2
|
|
|
3
|
-
Reqray NestJS
|
|
3
|
+
Reqray for NestJS: 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
|
-
|
|
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
|
+

|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
## Use
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @reqray/nestjs @reqray/register
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { Module } from '@nestjs/common';
|
|
16
|
+
import { ReqrayModule } from '@reqray/nestjs';
|
|
17
|
+
|
|
18
|
+
@Module({
|
|
19
|
+
imports: [ReqrayModule.forRoot()],
|
|
20
|
+
})
|
|
21
|
+
export class AppModule {}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
node --import @reqray/register dist/main.js
|
|
26
|
+
# open http://localhost:3000/_reqray/
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
One module in `imports`, nothing else. The platform — Express or Fastify — is
|
|
30
|
+
detected on its own. Exceptions are observed, not handled: your own exception
|
|
31
|
+
filters keep deciding the response, and Reqray records what was thrown.
|
|
32
|
+
|
|
33
|
+
`--import @reqray/register` is what instruments the database driver, the cache
|
|
34
|
+
client and `fetch`.
|
|
35
|
+
|
|
36
|
+
NestJS 10 and 11. Node 20 or newer.
|
|
37
|
+
|
|
38
|
+
## Options
|
|
39
|
+
|
|
40
|
+
`forRoot` takes the same options as the other adapters:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
ReqrayModule.forRoot({
|
|
44
|
+
panel: { gate: ({ headers }) => headers['x-admin'] === process.env.ADMIN_KEY },
|
|
45
|
+
redact: { headers: ['x-api-key'] },
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
| Option | Default | What it does |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| `enabled` | `NODE_ENV !== 'production'` | Off means off: nothing is recorded and nothing is mounted |
|
|
52
|
+
| `mode` | from `NODE_ENV` | `'development'` keeps every request; `'production'` samples |
|
|
53
|
+
| `panel` | `{ path: '/_reqray' }` | `false` to not mount it; `{ gate }` decides who gets in |
|
|
54
|
+
| `transport` | memory, last 500 requests | Where records go — see `@reqray/store-sqlite`, `@reqray/transport-http`, `@reqray/transport-file` |
|
|
55
|
+
| `redact` | see below | `{ headers: [...], body: [...] }` extend the masked names |
|
|
56
|
+
| `detect` | all on | `{ nPlusOne: { threshold: 10 }, slowBudget: false }` |
|
|
57
|
+
| `sampling` | 100% locally, 1% in production | `{ rate, slowMs, alwaysOnError, alwaysOnFinding }` |
|
|
58
|
+
| `replay`, `explain`, `blame` | local development only | Opt-in anywhere else |
|
|
59
|
+
| `collectSqlValues` | `false` | SQL parameter values are never recorded unless you ask |
|
|
60
|
+
|
|
61
|
+
Masked before anything is stored: `authorization`, `cookie`, `set-cookie` in
|
|
62
|
+
headers; `password`, `token`, `secret`, `cardNumber`, `cvv`, `apiKey`,
|
|
63
|
+
`signature` in bodies and query strings.
|
|
64
|
+
|
|
65
|
+
Outside local development the panel does not mount without an explicit gate —
|
|
66
|
+
the application fails at startup with an explanation rather than opening
|
|
67
|
+
access. `panel: { gate: 'open' }` if open is what you mean, or a function:
|
|
68
|
+
`gate: ({ headers, ip }) => headers['x-admin'] === process.env.ADMIN_KEY`.
|
|
69
|
+
|
|
70
|
+
## More
|
|
71
|
+
|
|
72
|
+
Everything else — the detectors, security defaults, measured overhead and a
|
|
73
|
+
demo that runs with one command — is in the
|
|
10
74
|
[main README](https://github.com/reqray/reqray#readme).
|
|
11
75
|
|
|
12
76
|
## License
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reqray/nestjs",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Reqray NestJS
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Reqray for NestJS: one module in imports, and every request is a waterfall with its SQL, cache and outgoing calls. Finds N+1 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.
|
|
52
|
-
"@reqray/
|
|
53
|
-
"@reqray/
|
|
51
|
+
"@reqray/core": "^0.1.1",
|
|
52
|
+
"@reqray/fastify": "^0.1.1",
|
|
53
|
+
"@reqray/express": "^0.1.1"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@nestjs/common": "^10 || ^11",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"rxjs": "^7.8.2",
|
|
70
70
|
"tsup": "^8.5.1",
|
|
71
71
|
"typescript": "^6.0.3",
|
|
72
|
-
"@reqray/store-memory": "^0.1.
|
|
72
|
+
"@reqray/store-memory": "^0.1.1"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
75
|
"build": "tsup",
|