7
votes

I'm new to both Node and Hapi.js, but not to programming.

I've made a few simple Hapi.js servers, just for testing out Joi and other plugins.

I'm now trying to understand how best to package up chunks of functionality in a Hapi way, so we can re-use them in future projects and potentially share them with the world!

Are there any good resources for learning this available?

EDIT: I've found a few good resources, but non which go into deep details about the plugin system.

2

2 Answers

7
votes

I've made a sample project which groups functionality into plugins which might be what you're looking for:

https://github.com/johnbrett/hapi-level-sample

If you're looking at sharing functionality between plugins, look at the usage of plugin.expose, plugin.depend.

If you have any questions on it, you can raise an issue on the github project.

The latest hapijs.com website has a good intro as well: http://hapijs.com/tutorials/plugins

2
votes

For some additional detail about hapi plugins (and hapi in general), see the following:

Edit 2015-10-04: The chapter "Building modular applications with Plugins" in Matt Harrison's above mentioned book is now available in the MEAP edition.