Hapi’ly developing Node.js applications

Reminding me slightly of early Java web applications that existed before Apache Struts came along, similarly, Node,js applications developed by different teams and developers can vary widely in terms of structure and style.

From wildly different index.js files to custom express() and mvc patterns it can be difficult moving from one project to another and learning the new style imposed.

Although there are many frameworks for building web applications with Node.js, now, with the advent of Hapi.js though, Node applications for websites, APIs, single page applications or any kind of networked JavaScript HTTP service are now fun and familiar to work with.

Designed in a modular fashion and with a configuration-over-coding approach, hapi was created by Walmart Labs so that their geographically located teams could collaborate more productively on larger projects – in fact most of Walmart’s traffic now runs on Hapi.js applications.

Central to Hapi.js success is its simple but powerful plugin system which allows functionality to be grouped and packaged together. Plugins can contain business logic, utilities, routes, server methods. So if you implement some functionality and want to share it with others you can share it with others as an npm package and just register the plugin in any other hapi application. Similarly a large application can be broken up into a series of Hapi plugins – the plugins can exist in a single codebase for the sole purpose of tidiness as well as for the purpose of wanting to share them. In fact ideally all applications should be split entirely into plugins with the root of the application just being responsible for basic configuration and the loading of plugins.

A Hapi plugin ecosystem (https://hapijs.com/plugins) provides a multitude of modules helping you to save further time implementing functionality that has already been implemented by others – Our favourite was the ‘Joi’ plugin for JSON validation.

Recently we had the pleasure of using Hapi to develop an micro-service based application for one of our clients (Vroom.com) and we can only say great things about it – it really makes working with Node applications so much more easier.

So what are you waiting for?, download Hapi.js and quickly start developing your next enterprise scale app today!

FYI – A great Hapi.js reference is Manning’s “hapi.js IN ACTION” – a super read.

https://hapijs.com/

https://www.manning.com/books/hapi-js-in-action

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

By submitting this form, you accept the Mollom privacy policy.