@@ -24,7 +24,16 @@ import { APIToolkit } from 'apitoolkit-express';
24
24
const app = express ();
25
25
app .use (express .json ());
26
26
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
+ );
28
37
29
38
app .get (' /hello/:name' , (req , res ) => {
30
39
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
54
63
| ` captureRequestBody ` | Default ` false ` , set to ` true ` if you want to capture the request body. |
55
64
| ` captureResponseBody ` | Default ` false ` , set to ` true ` if you want to capture the response body. |
56
65
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
-
86
66
<br />
87
67
88
68
> [ !IMPORTANT]
0 commit comments