1.0.14 • Published 2 years ago
foxyiti-api-monitoring-node-express v1.0.14
Foxyiti API Monitoring -> NodeJS | Express
Installation
yarn
$ yarn add foxyiti-api-monitoring-node-express
npm
$ npm i foxyiti-api-monitoring-node-express --save
In NodeJS
# import package
const { middleware } = require('foxyiti-api-monitoring-node-express');
# apply as express middleware to monitor all API
app.use(middleware());
# import package
const { middleware } = require('foxyiti-api-monitoring-node-express');
# Add middleware in specific APIs which has to be monitored
app.get('/', middleware(), (req, res) => {
...
...
});
app.post('/', middleware(), (req, res) => {
...
...
});
# This particular API will not be monitored
app.delete('/', (req, res) => {
...
...
});
Options
Options are not mandatory.
Options | Mandatory | Default | Values |
---|---|---|---|
exclude | FALSE | {} | { GET: [], POST: [], PATCH: [], DELETE: [], } |
Exclude
- Excludes the given API path's for each method. These API are not monitored.
- You can use express way of applying/ not applying global middleware to specific routes.
# import package
const { middleware } = require('foxyiti-api-monitoring-node-express');
const options = {
exclude: {
GET: ['/', '/health'],
}
};
# '/' and '/health' APIs of GET method are not monitored
app.use(middleware(options));