Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apitoolkit/apitoolkit-express
APItoolkit's Express client SDK.
https://github.com/apitoolkit/apitoolkit-express
apitoolkit apitoolkit-sdk expressjs javascript nestjs nodejs typescript
Last synced: about 17 hours ago
JSON representation
APItoolkit's Express client SDK.
- Host: GitHub
- URL: https://github.com/apitoolkit/apitoolkit-express
- Owner: apitoolkit
- Created: 2022-08-25T12:54:38.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-28T13:10:12.000Z (11 days ago)
- Last Synced: 2024-10-28T16:51:59.958Z (10 days ago)
- Topics: apitoolkit, apitoolkit-sdk, expressjs, javascript, nestjs, nodejs, typescript
- Language: JavaScript
- Homepage: https://apitoolkit.io/docs/sdks/nodejs/expressjs
- Size: 1.08 MB
- Stars: 6
- Watchers: 3
- Forks: 4
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
APIToolkit Express Middleware is a middleware that can be used to monitor HTTP requests. It is provides additional functionalities on top of the open telemetry instrumentation which creates a custom span for each request capturing details about the request including request and response bodies.
### Installation
Run the following command to install the express js package from your projects root:
```sh
npm install apitoolkit-express```
### Project setup
Intialize apitoolkit into your project like so:
```js
import express from 'express';
import { APIToolkit } from 'apitoolkit-express';const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(
APIToolkit.middleware({
serviceName: 'my-service',
redactHeaders: ['authorization', 'cookie'],
redactResponseBody: ['$.creditCardNumber'], // jsonpath to redact credit card number from response body
redactRequestBody: ['$.password'], // jsonpath to redact password from request body
captureRequestBody: true, // capture request body and send it to your apitoolkit dashboard
captureResponseBody: true // capture response body and send it to your apitoolkit dashboard
})
);app.get('/hello/:name', (req, res) => {
res.json({ message: `Hello ${req.params.name}!` });
});// comes after all other route handlers
app.use(APIToolkit.errorMiddleware());app.listen(3000, () => {
console.log('Server started on port 3000');
});
```#### Quick overview of the configuration parameters
An object with the following optional fields can be passed to the middleware to configure it:
| Option | Description |
| --------------------- | ------------------------------------------------------------------------------------------------- |
| `debug` | Set to `true` to enable debug mode. |
| `serviceName` | A defined string name of your application. |
| `tags` | A list of defined tags for your services (used for grouping and filtering data on the dashboard). |
| `serviceVersion` | A defined string version of your application (used for further debugging on the dashboard). |
| `redactHeaders` | A list of HTTP header keys to redact. |
| `redactResponseBody` | A list of JSONPaths from the response body to redact. |
| `redactRequestBody` | A list of JSONPaths from the request body to redact. |
| `captureRequestBody` | Default `false`, set to `true` if you want to capture the request body. |
| `captureResponseBody` | Default `false`, set to `true` if you want to capture the response body. |
> [!IMPORTANT]
>
> To learn more configuration options (redacting fields, error reporting, outgoing requests, etc.) and complete integration guide, please read this [SDK documentation](https://apitoolkit.io/docs/sdks/nodejs/expressjs/utm_campaign=devrel&utm_medium=github&utm_source=sdks_readme).