1.5.0 • Published 2 years ago
@apilytics/next v1.5.0
@apilytics/next
Apilytics is a service that lets you analyze operational, performance and security metrics from your APIs easily.
Installation
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/next
# OR
npm install @apilytics/next
- 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 is
undefined
.
pages/api/my-route.js
:
import { withApilytics } from '@apilytics/next';
const handler = async (req, res) => {
// ...
};
// Ideally the outermost middleware that you wrap your handler with.
export default withApilytics(handler, process.env.APILYTICS_API_KEY);
Frequently Asked Questions
Does the middleware slow down my backend?
- 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.
What 3rd party dependencies does @apilytics/next
have?
- None besides Next.js itself.
What Node.js versions does the package work with?
@apilytics/next
is tested to work on all the currently supported versions of Node: 12, 14, 16, and 17.