Fastify is web framework for node.js.
Moesif is an API analytics and Monetization platform.
moesif-nodejs is a middleware that makes integration with Moesif easy for Nodejs based apps including Express.
This example is a Fastify application with Moesif's API analytics middleware integrated.
Per fastify documentation, by default,
fastify do NOT support any middleware out of the box. You must use one of two plugins: @fastify/express
or @fastify/middie
in order to use ANY middleware.
- Install all dependencies:
npm install
- Add your Moesif Application Id to
server.js
Your Moesif Application Id can be found in the Moesif Portal. After signing up for a Moesif account, your Moesif Application Id will be displayed during the onboarding steps.
You can always find your Moesif Application Id at any time by logging into the Moesif Portal, clicking on the bottom-left menu, and then clicking Installation.
const moesifOptions = {
applicationId: "your application id"
};
- Run the example, it will listen on port 5000.
node server.js
- Send some requests to some of the routes and verify that the API calls are captured in your Moesif account.
curl http://localhost:3050