Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit ae08d2a

Browse files
committed
update docs
1 parent 43dda28 commit ae08d2a

File tree

1 file changed

+10
-30
lines changed

1 file changed

+10
-30
lines changed

README.md

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,16 @@ import { APIToolkit } from 'apitoolkit-express';
2424
const app = express();
2525
app.use(express.json());
2626
app.use(express.urlencoded({ extended: true }));
27-
app.use(APIToolkit.middleware());
27+
app.use(
28+
APIToolkit.middleware({
29+
serviceName: 'my-service',
30+
redactHeaders: ['authorization', 'cookie'],
31+
redactResponseBody: ['$.creditCardNumber'], // jsonpath to redact credit card number from response body
32+
redactRequestBody: ['$.password'], // jsonpath to redact password from request body
33+
captureRequestBody: true, // capture request body and send it to your apitoolkit dashboard
34+
captureResponseBody: true // capture response body and send it to your apitoolkit dashboard
35+
})
36+
);
2837

2938
app.get('/hello/:name', (req, res) => {
3039
res.json({ message: `Hello ${req.params.name}!` });
@@ -54,35 +63,6 @@ An object with the following optional fields can be passed to the middleware to
5463
| `captureRequestBody` | Default `false`, set to `true` if you want to capture the request body. |
5564
| `captureResponseBody` | Default `false`, set to `true` if you want to capture the response body. |
5665

57-
### Usage with configuration parameters
58-
59-
```js
60-
import express from 'express';
61-
import { APIToolkit } from 'apitoolkit-express';
62-
63-
const app = express();
64-
app.use(express.json());
65-
app.use(express.urlencoded({ extended: true }));
66-
app.use(
67-
APIToolkit.middleware({
68-
serviceName: 'my-service',
69-
redactHeaders: ['authorization', 'cookie'],
70-
redactResponseBody: ['$.creditCardNumber'], // jsonpath to redact credit card number from response body
71-
redactRequestBody: ['$.password'], // jsonpath to redact password from request body
72-
captureRequestBody: true,
73-
captureResponseBody: true
74-
})
75-
);
76-
77-
app.get('/hello/:name', (req, res) => {
78-
res.json({ message: `Hello ${req.params.name}!` });
79-
});
80-
81-
app.listen(3000, () => {
82-
console.log('Server started on port 3000');
83-
});
84-
```
85-
8666
<br />
8767

8868
> [!IMPORTANT]

0 commit comments

Comments
 (0)