We've seen briefly in the previous chapters how to register third-party plugins to a hapi server, and the power that they have in being able to add custom handlers, routes, or print our routing table on startup. hapi's plugin system is powerful, extensive, and at the level where not only is the plugin system useful for integrating third-party modules, but also a great abstraction for breaking up your application into smaller, reusable chunks of code. Let's take one of our examples from the previous chapters, and show how we can break up our business logic into more manageable chunks using plugins.
Encapsulating functionality within plugins
If you remember, in the first chapter, we looked at what a full server with a single route added ...