From 175237399a8642b59f455b0470598921b692407f Mon Sep 17 00:00:00 2001 From: Rafael Gonzaga Date: Fri, 14 Jun 2019 15:32:36 -0300 Subject: [PATCH] docs: Change location to display routes Was changed the location of display routes, because sometimes when `console.log` is called, the `avvio.after` cannot register the route yet. To prevent copy/paste deception. --- README.md | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index d8fccb2..644c10f 100644 --- a/README.md +++ b/README.md @@ -9,30 +9,36 @@ before registering any routes so that it can collect all of them. ## Example ```js +const fastify = require('fastify')() fastify.register(require('fastify-routes')) -fastify.get('/hello', opts, (request, reply) => { +fastify.get('/hello', {}, (request, reply) => { reply.send({ hello: 'world' }) }) -console.log(fastify.routes) - -/* will output a Map with entries: -{ - '/hello': { - get: { - method: 'GET', - url: '/hello', - schema: Object, - handler: , - prefix: , - logLevel: , - bodyLimit: +fastify.listen(3000, (err, address) => { + if (err) { + console.error(err) + return + } + console.log(fastify.routes) + /* will output a Map with entries: + { + '/hello': { + get: { + method: 'GET', + url: '/hello', + schema: Object, + handler: , + prefix: , + logLevel: , + bodyLimit: + } } } -} -*/ + */ +}) ```