I'm learning Hapi/MySQL now and I thought it would be fun to share what I learned through a series here.
Alos, to make this series even more interesting, fun, and easy to read, I will present it through a story of a person learning HapiJS. The person is Joe — an ambitious man who determined to build a software as a service app.
Obviously, since I'm still learning it, I am not a Hapi/MySQL expert. So, please do understand that whatever I tell you in this series comes from a fellow learner's perspective, not as a Hapi or MySQL expert.
And technically, you should have the following programs installed:
Alright, I think it's enough for the introduction. Let's start Joe's story.
And for the Node framework, he chose HapiJS.
So what is Hapi and why Joe chose it?
Here is what Joe found in his research.
On Hapi's official site. Joe found these:
- "The Simple, Secure Framework Developers Trust"
- "Build powerful, scalable applications, with minimal overhead and full out-of-the-box functionality"
- "Originally developed to handle Walmart’s Black Friday scale."
"If it's simple then I'll be able to understand it easily. If it's secure then it would save me a lot of trouble on a security matter that I am clueless about. If it's full out-of-the-box functionality then I don't need to deal with much third-party library. And if it can handle Walmart's Black Friday, then surely it can handle my simple app!", John said to himself.
Joe also found these convincing pieces of information from DWYL's Learn Hapi repo:
- WalmartLabs are the guys who found/solved the Node.js CORE Memory Leak; they have developed Hapi following Benchmark Driven Development and the result is a high-performance framework
- The Lead Developer of Hapi is Eran Hammer who was one of the original authors of the OAuth (Secure Authentication) Spec. He has built a security-focussed mindset into Hapi and reviews all code included in Hapi. Several members of the Node Security Project are core contributors to Hapi which means there are many security-minded eyes on the code.
So that's Hapi and why Joe chose it.
Joe decided that he should build a point of sale app. The reason is that he wanted to modernize his wife's retail store. Until now, the store's transaction was still recorded using pen and paper. For some basic usage, it's pretty convenient. However, when it comes to searching and analyzing the transaction, it's a nightmare!
In order to be useful to power his wife's store digitally, Joe thought that the app should have the following features:
- Recording sales (obviously)
- Ability to sell on credit
- Applying discount
- Creating multiple stores
- Tracking inventory
- Transfer order
- Purchase order
- Stock Adjustment
- Multiple roles: owner & employee
Also, Joe wanted his app to have the following features so he can offer the app to other store owner and make money from it:
- Offering subscription plan
- Accepting payment
Then Joe began his research on how to make that kind of app. Soon he realized that the app is not trivial. It requires comprehensive learning of backend development. At least he should be able to do the following tasks to turn his idea into reality:
- Creating server
- Defining endpoints of various HTTP methods
- Handling user request
- Defining model
- Working with database
- Authentication with JWT
After defining the goals, now Joe is ready to embark on his first journey on learning HapiJS.