How to make a Hapi.JS plugin / module?

I am new to both Node and Hapi.js, but not for programming.

I created some simple Hapi.js servers, just for testing Joi and other plugins.

Now I'm trying to figure out how best to pack pieces of functionality in Hapi style, so we can reuse them in future projects and potentially share them with the world!

Are there any good resources to study this?

EDIT: I found some good resources, but without going into details about the plugin system.

+7
module plugins hapijs
source share
2 answers

I made a sample project that groups functionality into plugins, which may be what you are looking for:

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

If you are looking at function sharing between plugins, look at using plugin.expose, plugin.depend.

If you have any questions about this, you can raise the issue in the github project.

The latest hapijs.com website has a good introduction: http://hapijs.com/tutorials/plugins

+7
source share

For more information on hapi plugins (and generally hapi), see the following:

Edit 2015-10-04: In the chapter "Creating Modular Applications with Plugins" in Matt Harrison, the above-mentioned book now has a version of MEAP available.

+2
source share

All Articles