DEV Community

Jalu Pujo Rumekso
Jalu Pujo Rumekso

Posted on • Edited on • Originally published at jprumekso.github.io

Barebone Hapi 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:

SurveyJS custom survey software

Build Your Own Forms without Manual Coding

SurveyJS UI libraries let you build a JSON-based form management system that integrates with any backend, giving you full control over your data with no user limits. Includes support for custom question types, skip logic, an integrated CSS editor, PDF export, real-time analytics, and more.

Learn more

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

Instrument, monitor, fix: a hands-on debugging session

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️