request-scope-api 1.0.16 → 1.0.19
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
CHANGED
|
@@ -16,16 +16,16 @@ npm install request-scope-api
|
|
|
16
16
|
|
|
17
17
|
```javascript
|
|
18
18
|
import express from 'express';
|
|
19
|
-
import
|
|
19
|
+
import { setup } from 'request-scope-api';
|
|
20
20
|
|
|
21
21
|
const app = express();
|
|
22
22
|
|
|
23
|
-
app
|
|
23
|
+
setup(app, {
|
|
24
24
|
storage: {
|
|
25
25
|
type: 'mongodb',
|
|
26
26
|
uri: 'mongodb://localhost:27017/myapp'
|
|
27
27
|
}
|
|
28
|
-
})
|
|
28
|
+
});
|
|
29
29
|
|
|
30
30
|
app.listen(3000);
|
|
31
31
|
```
|
|
@@ -34,20 +34,23 @@ app.listen(3000);
|
|
|
34
34
|
|
|
35
35
|
```javascript
|
|
36
36
|
import express from 'express';
|
|
37
|
-
import
|
|
37
|
+
import { setup } from 'request-scope-api';
|
|
38
38
|
|
|
39
39
|
const app = express();
|
|
40
40
|
|
|
41
|
-
app
|
|
41
|
+
setup(app, {
|
|
42
42
|
storage: {
|
|
43
43
|
type: 'mysql',
|
|
44
44
|
host: 'localhost',
|
|
45
45
|
port: 3306,
|
|
46
|
-
database: '
|
|
47
|
-
username: '
|
|
48
|
-
password: '
|
|
49
|
-
}
|
|
50
|
-
|
|
46
|
+
database: 'truck_match_live_leatest',
|
|
47
|
+
username: 'root',
|
|
48
|
+
password: ''
|
|
49
|
+
},
|
|
50
|
+
retentionDays: 30,
|
|
51
|
+
ignore: ['/health', '/favicon.ico'],
|
|
52
|
+
maskFields: ['password']
|
|
53
|
+
});
|
|
51
54
|
|
|
52
55
|
app.listen(3000);
|
|
53
56
|
```
|
|
@@ -56,11 +59,11 @@ app.listen(3000);
|
|
|
56
59
|
|
|
57
60
|
```javascript
|
|
58
61
|
import express from 'express';
|
|
59
|
-
import
|
|
62
|
+
import { setup } from 'request-scope-api';
|
|
60
63
|
|
|
61
64
|
const app = express();
|
|
62
65
|
|
|
63
|
-
app
|
|
66
|
+
setup(app, {
|
|
64
67
|
storage: {
|
|
65
68
|
type: 'postgresql',
|
|
66
69
|
host: 'localhost',
|
|
@@ -69,123 +72,11 @@ app.use(request-scope-api({
|
|
|
69
72
|
username: 'user',
|
|
70
73
|
password: 'pass'
|
|
71
74
|
}
|
|
72
|
-
})
|
|
75
|
+
});
|
|
73
76
|
|
|
74
77
|
app.listen(3000);
|
|
75
78
|
```
|
|
76
79
|
|
|
77
|
-
## Dashboard
|
|
78
|
-
|
|
79
|
-
Mount the dashboard at a specific path with optional authentication:
|
|
80
|
-
|
|
81
|
-
```javascript
|
|
82
|
-
import request-scope-api from 'request-scope-api';
|
|
83
|
-
|
|
84
|
-
const app = express();
|
|
85
|
-
|
|
86
|
-
// Capture middleware
|
|
87
|
-
app.use(request-scope-api({
|
|
88
|
-
storage: {
|
|
89
|
-
type: 'mongodb',
|
|
90
|
-
uri: 'mongodb://localhost:27017/myapp'
|
|
91
|
-
}
|
|
92
|
-
}));
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
## Configuration
|
|
96
|
-
|
|
97
|
-
### request-scope-apiConfig
|
|
98
|
-
|
|
99
|
-
| Option | Type | Default | Description |
|
|
100
|
-
|--------|------|---------|-------------|
|
|
101
|
-
| `storage` | `StorageConfig` | **required** | Database storage configuration |
|
|
102
|
-
| `retentionDays` | `number` | `30` | Number of days to retain records (1-365) |
|
|
103
|
-
| `ignore` | `string[]` | `[]` | URL paths to skip (no capture) |
|
|
104
|
-
| `maskFields` | `string[]` | `[]` | Additional field names to mask (merged with built-in defaults) |
|
|
105
|
-
| `dashboard` | `DashboardConfig` | `undefined` | Dashboard configuration |
|
|
106
|
-
|
|
107
|
-
### StorageConfig
|
|
108
|
-
|
|
109
|
-
| Option | Type | Required For | Description |
|
|
110
|
-
|--------|------|---------------|-------------|
|
|
111
|
-
| `type` | `'mongodb' \| 'mysql' \| 'postgresql'` | All | Storage backend type |
|
|
112
|
-
| `uri` | `string` | MongoDB | MongoDB connection URI |
|
|
113
|
-
| `host` | `string` | MySQL, PostgreSQL | Database host |
|
|
114
|
-
| `port` | `number` | MySQL, PostgreSQL | Database port |
|
|
115
|
-
| `database` | `string` | MySQL, PostgreSQL | Database name |
|
|
116
|
-
| `username` | `string` | MySQL, PostgreSQL | Database username |
|
|
117
|
-
| `password` | `string` | MySQL, PostgreSQL | Database password |
|
|
118
|
-
| `poolSize` | `number` | All | Connection pool size (default: 5) |
|
|
119
|
-
| `ssl` | `boolean` | All | Enable SSL/TLS (default: false) |
|
|
120
|
-
|
|
121
|
-
### DashboardConfig
|
|
122
|
-
|
|
123
|
-
| Option | Type | Default | Description |
|
|
124
|
-
|--------|------|---------|-------------|
|
|
125
|
-
| `auth` | `AuthConfig` | `undefined` | Authentication configuration |
|
|
126
|
-
| `mountPath` | `string` | `"/request-scope-api"` | Mount path for the dashboard |
|
|
127
|
-
|
|
128
|
-
### AuthConfig
|
|
129
|
-
|
|
130
|
-
| Option | Type | Description |
|
|
131
|
-
|--------|------|-------------|
|
|
132
|
-
| `username` | `string` | Basic auth username |
|
|
133
|
-
| `password` | `string` | Basic auth password |
|
|
134
|
-
|
|
135
|
-
## Database-Specific Setup
|
|
136
|
-
|
|
137
|
-
### MongoDB
|
|
138
|
-
|
|
139
|
-
- **URI Format**: `mongodb://[username:password@]host[:port][/database][?options]`
|
|
140
|
-
- **Required Fields**: `uri`
|
|
141
|
-
- **Optional**: `poolSize`, `ssl`
|
|
142
|
-
|
|
143
|
-
Example:
|
|
144
|
-
```javascript
|
|
145
|
-
storage: {
|
|
146
|
-
type: 'mongodb',
|
|
147
|
-
uri: 'mongodb://user:pass@localhost:27017/myapp?authSource=admin'
|
|
148
|
-
}
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### MySQL
|
|
152
|
-
|
|
153
|
-
- **Required Fields**: `host`, `port`, `database`, `username`, `password`
|
|
154
|
-
- **Optional**: `poolSize`, `ssl`
|
|
155
|
-
|
|
156
|
-
Example:
|
|
157
|
-
```javascript
|
|
158
|
-
storage: {
|
|
159
|
-
type: 'mysql',
|
|
160
|
-
host: 'localhost',
|
|
161
|
-
port: 3306,
|
|
162
|
-
database: 'myapp',
|
|
163
|
-
username: 'user',
|
|
164
|
-
password: 'pass',
|
|
165
|
-
poolSize: 10,
|
|
166
|
-
ssl: true
|
|
167
|
-
}
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### PostgreSQL
|
|
171
|
-
|
|
172
|
-
- **Required Fields**: `host`, `port`, `database`, `username`, `password`
|
|
173
|
-
- **Optional**: `poolSize`, `ssl`
|
|
174
|
-
|
|
175
|
-
Example:
|
|
176
|
-
```javascript
|
|
177
|
-
storage: {
|
|
178
|
-
type: 'postgresql',
|
|
179
|
-
host: 'localhost',
|
|
180
|
-
port: 5432,
|
|
181
|
-
database: 'myapp',
|
|
182
|
-
username: 'user',
|
|
183
|
-
password: 'pass',
|
|
184
|
-
poolSize: 10,
|
|
185
|
-
ssl: true
|
|
186
|
-
}
|
|
187
|
-
```
|
|
188
|
-
|
|
189
80
|
## Features
|
|
190
81
|
|
|
191
82
|
- **Zero Configuration**: Works out of the box with sensible defaults
|
|
@@ -211,10 +102,10 @@ request-scope-api automatically masks sensitive fields in request headers, reque
|
|
|
211
102
|
Add custom fields to mask via the `maskFields` configuration:
|
|
212
103
|
|
|
213
104
|
```javascript
|
|
214
|
-
app
|
|
105
|
+
setup(app, {
|
|
215
106
|
storage: { /* ... */ },
|
|
216
107
|
maskFields: ['creditCard', 'ssn', 'apiKey']
|
|
217
|
-
})
|
|
108
|
+
});
|
|
218
109
|
```
|
|
219
110
|
|
|
220
111
|
## Ignoring Paths
|
|
@@ -222,10 +113,10 @@ app.use(request-scope-api({
|
|
|
222
113
|
Skip capture for specific URL paths:
|
|
223
114
|
|
|
224
115
|
```javascript
|
|
225
|
-
app
|
|
116
|
+
setup(app, {
|
|
226
117
|
storage: { /* ... */ },
|
|
227
118
|
ignore: ['/health', '/metrics', '/favicon.ico']
|
|
228
|
-
})
|
|
119
|
+
});
|
|
229
120
|
```
|
|
230
121
|
|
|
231
122
|
## Error Handling
|
|
@@ -233,9 +124,9 @@ app.use(request-scope-api({
|
|
|
233
124
|
To capture error data, use the provided error middleware:
|
|
234
125
|
|
|
235
126
|
```javascript
|
|
236
|
-
import
|
|
127
|
+
import { setup, errorHandler } from 'request-scope-api';
|
|
237
128
|
|
|
238
|
-
app
|
|
129
|
+
setup(app, { /* ... */ });
|
|
239
130
|
app.use(errorHandler);
|
|
240
131
|
|
|
241
132
|
// Your routes
|
|
@@ -247,29 +138,3 @@ app.get('/api/users', async (req, res, next) => {
|
|
|
247
138
|
}
|
|
248
139
|
});
|
|
249
140
|
```
|
|
250
|
-
|
|
251
|
-
## API Endpoints
|
|
252
|
-
|
|
253
|
-
The dashboard provides the following API endpoints:
|
|
254
|
-
|
|
255
|
-
- `GET /api/records` - List records with filtering, sorting, and pagination
|
|
256
|
-
- `GET /api/records/:id` - Get a single record by ID
|
|
257
|
-
|
|
258
|
-
### Query Parameters (GET /api/records)
|
|
259
|
-
|
|
260
|
-
| Parameter | Type | Description |
|
|
261
|
-
|-----------|------|-------------|
|
|
262
|
-
| `search` | `string` | Case-insensitive substring match on URL |
|
|
263
|
-
| `startDate` | `string` | ISO 8601 timestamp (inclusive lower bound) |
|
|
264
|
-
| `endDate` | `string` | ISO 8601 timestamp (inclusive upper bound) |
|
|
265
|
-
| `statusCodeGroup` | `string` | Status code group: `2xx`, `3xx`, `4xx`, `5xx` |
|
|
266
|
-
| `statusCode` | `number` | Exact status code match |
|
|
267
|
-
| `method` | `string` | Exact HTTP method match (case-insensitive) |
|
|
268
|
-
| `sortBy` | `string` | Sort field: `timestamp`, `responseTime`, `statusCode` |
|
|
269
|
-
| `sortOrder` | `string` | Sort order: `asc`, `desc` |
|
|
270
|
-
| `page` | `number` | Page number (default: 1) |
|
|
271
|
-
| `pageSize` | `number` | Page size (default: 25) |
|
|
272
|
-
|
|
273
|
-
## License
|
|
274
|
-
|
|
275
|
-
MIT
|
|
@@ -7,13 +7,9 @@
|
|
|
7
7
|
* A descending index on `timestamp` is created at initialization for sort
|
|
8
8
|
* performance and retention queries.
|
|
9
9
|
*/
|
|
10
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
-
};
|
|
13
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
11
|
exports.MongoAdapter = void 0;
|
|
15
|
-
const mongodb_1 =
|
|
16
|
-
const { MongoClient: MongoClientClass } = mongodb_1.default;
|
|
12
|
+
const mongodb_1 = require("mongodb");
|
|
17
13
|
// ---------------------------------------------------------------------------
|
|
18
14
|
// Helper: map statusCodeGroup → {$gte, $lt} range
|
|
19
15
|
// ---------------------------------------------------------------------------
|
|
@@ -67,7 +63,7 @@ class MongoAdapter {
|
|
|
67
63
|
return;
|
|
68
64
|
}
|
|
69
65
|
try {
|
|
70
|
-
this.client = new
|
|
66
|
+
this.client = new mongodb_1.MongoClient(uri);
|
|
71
67
|
await this.client.connect();
|
|
72
68
|
const db = this.client.db();
|
|
73
69
|
// Create the collection if it does not exist (MongoDB creates it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongo.adapter.js","sourceRoot":"","sources":["../../../src/adapters/mongo.adapter.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG
|
|
1
|
+
{"version":3,"file":"mongo.adapter.js","sourceRoot":"","sources":["../../../src/adapters/mongo.adapter.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,qCAAsC;AA+BtC,8EAA8E;AAC9E,kDAAkD;AAClD,8EAA8E;AAE9E,SAAS,gBAAgB,CAAC,KAAoC;IAC5D,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC;IAC1C,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GAAG,EAAE,MAAM,EAAE;SAC3B,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC,YAAY,CAAC;IAC7B,CAAC;CACF;AAlKD,oCAkKC"}
|
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
* A descending index on `timestamp` is created at initialization for sort
|
|
7
7
|
* performance and retention queries.
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
10
|
-
const { MongoClient: MongoClientClass } = mongodb;
|
|
9
|
+
import { MongoClient } from 'mongodb';
|
|
11
10
|
// ---------------------------------------------------------------------------
|
|
12
11
|
// Helper: map statusCodeGroup → {$gte, $lt} range
|
|
13
12
|
// ---------------------------------------------------------------------------
|
|
@@ -61,7 +60,7 @@ export class MongoAdapter {
|
|
|
61
60
|
return;
|
|
62
61
|
}
|
|
63
62
|
try {
|
|
64
|
-
this.client = new
|
|
63
|
+
this.client = new MongoClient(uri);
|
|
65
64
|
await this.client.connect();
|
|
66
65
|
const db = this.client.db();
|
|
67
66
|
// Create the collection if it does not exist (MongoDB creates it
|