Exposing and consuming plugins

In the previous section, we looked at how we can break up the business logic of our applications into smaller, more manageable chunks through plugins. We did this by attaching routes directly to the server object passed into the register, which is probably the simplest use case with plugins. But plugins won't always be used for just routing; you could perform logic on server start as with blipp, initialize database connections, create models for interacting with your data, and so on.

With developers still getting used to structuring server-side applications and the asynchronous nature of JavaScript, these types of use cases often are the beginning of messy or unstructured code due to the number of responsibilities ...

Get Getting Started with hapi.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.