Hapi.JS: How To Handle the Increased Complexity of Your Growing Team Without Needing to Constantly Refactor Your Code

Last Updated on: July 14, 2020

Hapi.JS: How To Handle the Increased Complexity of Your Growing Team Without Needing to Constantly Refactor Your Code

Hapi.js (pronounced “Happy”) is a Node.js framework that is a powerful, yet easy to use tool that helps you write performance-oriented, easy-to-maintain code.

Some background on Node.js:
In 2016, Apple, Sony, Intel, Siemens and Google all decided to adopt Node.js as their top choice for implementing their own backend and micro-services code.  With over 15 million downloads every month and over a billion package downloads per week, node.js is easily the biggest open-source platform ever.

But how can you use Node.js to effectively manage projects alongside a growing team?

This is where we believe Hapi can help:

Hapi.JS – Battle Tested on the Fields of Black Friday Shoppers at Wal-Mart

To give you an idea of just why the developer community believes Hapi.js is so robust and dependable, it was able to successfully manage thousands upon thousands of shopping transactions, returns and more at Wal-Mart during Black Friday, arguably the busiest retail shopping day of the year in the U.S. It does this by freely using plug-ins without making any one plug-in mandatory.  And although Hapi.js makes applications modular, it’s still very flexible.

Everything in the Hapi.js ecosystem is considered a plug-in — authentication strategies, function handlers (in the request lifecycle), routes and so forth.  Hapi.js recommends that developers focus on writing reusable application logic and keep two principles in mind while doing so:

  1. Configuration over convention

  2. Isolating business logic from the transport layer

Why Use Hapi.js?

Hapi.js is specifically designed to work in complex enterprise environments where multiple teams work on individual projects or overlapping pieces that must connect into one seamless result. By enabling developers to work on modular, reusable code without being narrowly constrained, developers can concentrate on the core project without trying to erect meta-frameworks or refactor the code.

To show this process in action, consider the typical Hapi.js request lifecycle:

Here you can see that the developer is provided with hooks, in the form of handlers and extensions, to implement the logic. Hapi.js largely stays out of what goes into these hooks. As project complexity grows, the need to decouple functionality and distribute the load also grows.  The Hapi server becomes the outward-facing interface (by way of an API or UI), while leveraging a wide array of other technologies to break down monoliths of business logic into smaller, bite-sized pieces (which can in turn be managed by Hapi).

If this is enough to pique your interest in using this adaptable framework, be sure to check out our boilerplate app — a free kit called Hapiness which provides an excellent starting point for all Hapi.js developers to use in their own production servers.

‘Hapiness’ is available for download on Github– check it out and be sure to let us know what you think!

Shaonika Saha

May 15, 2017

Leave a Reply

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