Chapter 2. Building an API

This chapter covers

  • Building an API with hapi.js
  • Integrating business logic
  • Working with databases

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.

2.1. Designing the API

This ...

Get hapi.js in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.