Chapter 2. Building an API
You saw in chapter 1 that hapi apps are constructed by working with servers, routes, handlers, plugins, and your own business logic. In this chapter, you’ll see how those pieces come together. First I introduce a fictional brief for an API project that I’m going to build. Next I figure out the technical requirements and plan the API endpoints. Then I move on to implementing this in hapi step-by-step.
I won’t be diving too deeply into any single component of hapi yet. Instead, I’m going to take a more high-level approach, giving you the bigger picture of how apps in hapi are built.
This section introduces a fictional HTTP API project that will be the focus of this chapter. First I gather some requirements for the API. Once it’s clear how the API should work, I design the endpoints through which clients can access the API.