Apilytics is a service that lets you analyze operational, performance and security metrics from your APIs easily.
-
Sign up and get your API key from https://apilytics.io - we offer a completely free trial with no credit card required!
-
Install this package:
yarn add @apilytics/express
# OR
npm install @apilytics/express
- Enable the middleware and set your API key:
A good practice is to securely store the API key as an environment variable. You can leave the env variable unset in e.g. development and test environments, the middleware will be automatically disabled if the key isundefined
.
server.js
:
const { apilyticsMiddleware } = require('@apilytics/express');
const express = require('express');
const app = express();
// Ideally the first middleware you add.
app.use(apilyticsMiddleware(process.env.APILYTICS_API_KEY));
- No. The middleware does all of its requests to the Apilytics API in the background, by using promises without awaiting them, so it will not slow down your normal request handling.
- None besides Express itself.
@apilytics/express
is tested to work on all the currently supported versions of Node: 12, 14, 16, and 17.