const fastify = require('fastify')
async function run() {
const app = fastify()
// await the plugin registration!
await app.register(require('fastify-overview'))
// create your application as usual
app.addHook('onSend', function hookRoot () {})
app.register(function register1 (instance, opts, next) {
instance.addHook('onRequest', function hook1 () {})
instance.register(function register2 (sub, opts, next) {
sub.addHook('onRequest', function hook2 () {})
next()
})
next()
})
// read your application structure when fastify is ready
let showIt
app.addHook('onReady', function showStructure (done) {
const appStructure = app.overview()
console.log(JSON.stringify(appStructure, null, 2))
showIt = appStructure
done(null)
})
await app.listen(3000)
return showIt
}
run()