Creating a Hapi web app
Hapi is a fairly recent addition to the Enterprise web framework offerings. The Hapi web framework has a reputation for stability, but tends to perform slower (for instance, see https://raygun.com/blog/node-performance/) while also requiring more boilerplate alternatives. With a contrasting philosophy and approach to Express (and other middleware frameworks such as Koa and Restify) Hapi may be better suited to certain and preferences. For instance, teams in large organizations that have a leaning towards Object Oriented Programming, particularly where Java is the prevailing tradition, may find Hapi more fitting to the cultural proclivities.
In this recipe, we'll create a simple Hapi web application.
Getting ready
Let's create a folder called app
, initialize it as a package, and install hapi
and inert
:
$ mkdir app$ cd app$ npm install --save hapi inert
How to do it...
Let's start by creating a few files:
$ touch index.js$ mkdir routes public$ touch routes/index.js$ touch...