Don't repeat yourself - why we use HAPI


When developing, we always want to keep to the mantra of keeping things DRY (Don’t Repeat Yourself). The reasoning is based on redoing work will probably introduce errors.

With our Node.js API’s, we initially started to use Express.js. However, we quickly found out that providing documentation and validating our incoming requests became pretty burdensome. We then found the HAPI.js project fitted exactly into our requirements of not repeating ourselves.

  1. Define the request contract - HAPI can validate the incoming request based on meta-data attached to the route.

  2. Ensure our response is consistent to our promise - HAPI also can validate outgoing responses to ensure that the contract published is being adhered to, as advertised.

  3. Advertisement of our API’s came free when we could easily generate our Swagger documentation off the meta-data provided in the above two steps.

So if you are starting a new project and would like to try something new, I strongly recommend giving the HAPI.js project an evaluation alongside the various plugins available to it.

blog comments powered by Disqus