Chapter 1. Introducing hapi
Listing 1.1. A jellybean library rich in methods
Listing 1.2. A jellybean library rich in configuration options
Listing 1.3. A simple hapi app that uses all the building blocks
Listing 1.4. Creating a hapi server
Listing 1.5. Adding routes to the server
Listing 1.6. Registering a plugin and starting the server
Chapter 2. Building an API
Listing 2.1. package.json
Listing 2.2. Creating a connection to SQLite using sqlite3
Listing 2.3. Querying a database for all recipes and printing each recipe’s name
Listing 2.4. Using placeholders to safely include variables in a SQL query
Listing 2.5. index.js: the route for endpoint A
Listing 2.6. index.js: the extended route for endpoint A
Listing 2.7. index.js: the new route for endpoint B
Listing 2.8. routes.js
Listing 2.9. index.js: using server.bind()
Listing 2.10. routes.js: using this.db to access database object
Listing 2.11. handlers/recipes.js: route handlers as exported functions
Listing 2.12. routes.js: using the new recipes handlers module
Listing 2.13. Creating two different strategies from the same scheme
Listing 2.14. Authentication routine in pseudocode
Listing 2.15. index.js: registering and configuring hapi-auth-bearer-token
Listing 2.16. index.js: implementing the validateFunc function
Listing 2.17. routes.js: updated for endpoint C
Listing 2.18. handlers/recipes.js: the create recipe handler
Chapter 3. Building a website
Listing 3.1. package.json
Listing 3.2. routes.js
Listing 3.3. index.js