Skip to content

☀️ Learn to use Hapi.js (Node.js) web framework to build scalable apps in less time

License

Notifications You must be signed in to change notification settings

cristinecula/learn-hapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Happiness Is...

Learn Hapi [ Work in Progress ]

Learn how to use the Hapi (Node.js) web framework to build scalable apps in less time.

What is Hapi?

Hapi is the framework for rapidly building RESTful web services in Node.js.
Whether you are building a very simple set of RESTful services for your website/mobile app to call or a large scale, cache heavy, and secure set of services, hapi has you covered. Hapi will help get your server developed quickly with its wide range of configurable options.

Video Intro:

Watch this video: http://youtu.be/BsyvnVOhp4U (good/recent intro to HAPI)

Why Hapi instead of XYZ framework?

Q: I already know how to build REST APIs in Express and Restify why learn a new framework?
A: If you are happy with your existing system & level of team productivity, stick with what you know. If not, learn [how to be] Hapi. (I have built Sites/APIs with both Express and Restify and find Hapi has solved more "real world" problems and thus I end up writing less code. YMMV. See benefits below)

Q: Hapi looks like quite a steep learning curve, how long will it take me to learn?
A: You can get started immediately with the simple examples below, it will take aprox 60 mins to complete them all. (after that add a couple of hours to read/learn further) the most important part is to try Hapi on a simple project to gain experience/confidence.

Key Benefits

  • Performance - WalmartLabs are the guys who found/solved the Node.js CORE Memory Leak they have developed Hapi follwing Benchmark Driven Development and the result is a high-performance framework.
  • Security - they have focussed on security and battle-tested the framework during Black Friday (holiday shopping busy day) without incident.
  • Mobile Optimised (lightweight - built for mobile e-commerce)
  • Plugin Architecture - easy to extend / add your own modules (good ecosystem)
  • DevOps Friendly (great stats logging) see: https://github.com/spumko/good
  • Built-in Caching (Redis, MongoDB or Memcached)
  • 100% Code Coverage (for the core)
  • Key Functionality is Built-in and good plugins add other functionality seamlessly.

Dive In!

Requirements

  • A computer that can run Node.js Mac/Windows/Linux/Chromebook
  • Access to the Internet (only required for installation)
  • 60 minutes of time.

Hello World in Hapi

Validation with Joi

Caching with Catbox

https://github.com/spumko/catbox/

Testing with Lab

https://medium.com/the-spumko-suite/testing-hapi-services-with-lab-96ac463c490a https://github.com/spumko/lab

Error Handling with Boom

Using Socket.io with Hapi

https://github.com/spumko/hapi/blob/master/examples/socketio.js Requires a bit more work...

Background Reading / Watching

Video Intro

Tutorials

Respond to this SO Q:




Warning: Hapi is built by Walmart

Hapi is Made by Walmart

Hapi is built by @WalmartLabs for Walmart.

Walmart is by far the most successful retailer in the world and they have achieved their success (in part) by investing heavily in their technological competitve advantage.

If you are not keen on Walmart for any of these reasons, at least consider the fact that they have open-sourced their full node stack to allow others to benefit from their hard work.

I took the time to read extensively about Walmart as part of my Retail course at University see: History of Walmart and In Sam We Trust. The fact is that Sam Walton acheived much of his success through investing in technology (Barcodes, EPOS, Satelite Uplink for Logistics Tracking, etc) to drive cost savings and passed those savings on to the customers where other retailers got left behind with their paper-based "it still works, why change?" approach.

Since Sam's passing the Walmart leadership has compromised its ethics in favor of maximising profits. This documented in: The High Cost Of Low Price and The Wal-Mart Effect

While I think we can/should continue send a clear message to Bentonville by prefering to spend our $¥£€ at Local & Fairtrade retailers where ever possible, we can still use the best-in-class code the fantastic engineers have built (to meet their vast supply-chain and e-commerce needs and open-sourced) to craft our own software products/projects.

Using the transport analogy, I don't like using fossil fuels to get from A-to-B because of the CO2 emmissions. But I'm pragmatic about how I travel the thousand miles to visit my family twice a year. I could do two weeks by horse-and-cart, two days by train or two hours by plane each way. Which option do you take...? By chosing Hapi you are opting for the jet-engine.

Make up your own mind on whether you feel that using code written for Walmart goes against your ethics.
If you find a better open-source Node.js stack that fits your needs, please tell me about it!

http://www.brainyquote.com/quotes/topics/topic_happiness.html

About

☀️ Learn to use Hapi.js (Node.js) web framework to build scalable apps in less time

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 85.1%
  • JavaScript 14.9%