diff --git a/README.md b/README.md index cdb34bae..1be82947 100644 --- a/README.md +++ b/README.md @@ -136,14 +136,19 @@ fastify.swagger() You need to register `@fastify/swagger` before registering routes. ```js -const fastify = require('fastify')() -const fastify = fastify() -await fastify.register(require('@fastify/swagger')) -fastify.register(require("@fastify/autoload"), { - dir: path.join(__dirname, 'routes') -}) -await fastify.ready() -fastify.swagger() + +const app = async () => { + // ... + + fastify.register(require('@fastify/swagger')) + + // load your routes + fastify.register(require("@fastify/autoload"), { + dir: path.join(__dirname, 'routes') + }) + + // ... +} ```