Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
itssimon committed Jan 22, 2024
1 parent 227628a commit 57b093c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ This is an example of how to register the Apitally plugin with a Fastify
application. For further instructions, see our
[setup guide for Fastify](https://docs.apitally.io/frameworks/fastify).

_Note:_ The Apitally plugin requires the
The Apitally plugin requires the
[`fastify-plugin`](https://www.npmjs.com/package/fastify-plugin) package to be
installed.

Expand All @@ -121,12 +121,22 @@ npm install fastify-plugin
const fastify = require("fastify")({ logger: true });
const { apitallyPlugin } = require("apitally/fastify");

await fastify.register(apitallyPlugin, {
fastify.register(apitallyPlugin, {
clientId: "your-client-id",
env: "dev", // or "prod" etc.
});

// Wrap your routes in a plugin, so Apitally can detect them
fastify.register((instance, opts, done) => {
instance.get("/", (request, reply) => {
reply.send("hello");
});
done();
});
```

_Note:_ If your project uses ES modules you can use `await fastify.register(...)` and don't need to wrap your routes in a plugin. See the [Fastify V4 migration guide](https://fastify.dev/docs/latest/Guides/Migration-Guide-V4/#synchronous-route-definitions-2954) for more details.

### Koa

This is an example of how to use the Apitally middleware with a Koa application.
Expand Down

0 comments on commit 57b093c

Please sign in to comment.