# Project Setup

It's a quiet night. No tv sound, no traffic sound, just a group of the cricket singing. Joe can't wait to open his laptop. He's been busy helping his wife running a multi-branch store all day long. Now he has the time, he feels happy and wants to jump directly into his own business. What business do you ask? The business of starting a Hapi project.

# Initialization

Joe began his project with git init and npm init. After filling out the details, he installed HapiJS by running npm install @hapi/hapi. He sees the terminal showing an installation progress bar. When the process is completed, he checks the size of his project folder. To his surprise, it's only 1.9 MB.

# Project Structure

After Hapi got installed, Joe begins to wonder about how to structure his project. Then he does a quick search for the best practices online. He finds people ask the same question at Stack Overflow and Hapi Github's issue. From those two sources, he finds many recommendations.

Then he decided that his project structure was like this:

  • assets (folder): contains static files such as images;
  • config (folder): contains app configurations
  • models (folder): contains data models
  • routes (folder): contains routes handlers
  • app.js: the app's main file or the entry point
  • package.json: a file created from npm init command
  • .gitignore: a file containing a list of files that need to be ignored by git

That structure is just his personal preference and he is happy with it.

Joe looks at the clock, it's 23:00, which is quite late for him since he has to wake up at 03:30 tomorrow. So he decides to call it a night and close his laptop.

Before he goes to sleep, he writes his target for learning Hapi tomorrow: creating my first Hapi server.

# References

Here are the references that Joe use to set up his project: