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.
If you remember, in the first chapter, we looked at what a full server with a single route added to it looks like, and used the blipp
module to print the routing table on server start. In the example, all the code is contained in one entry file. As long as you have one route, this is fine; however, as an application grows, this practice leads...