Chapter 3. Building a website

 

This chapter covers

  • Serving static content
  • Serving dynamic HTML with views
  • Working with external HTTP APIs from hapi.js
  • Managing user state with sessions

This chapter follows the building of a simple website to show off some of the front-end features in hapi.js. The website we’ll be creating builds on top of the API project from the previous chapter. It will retrieve data from the API and create dynamic web pages using this data.

Don’t worry if you haven’t followed along with the API project in chapter 2. The finished API has been released as an npm package called dindin-api, which we’ll use as a dependency in this chapter.

npm Package

We’ll be looking at how you can use hapi’s powerful plugin system to modularize your own applications in this way in chapter 5.

3.1. The DinDin website

Hey, and welcome back! If you’ve just joined us, we’re working for a client called Mrs. Bigbucks, a tech entrepreneur. We’re building a prototype for her latest venture, a food-oriented social network called DinDin. The idea is that people can post their own recipes online, and other people can search and star their favorites.

3.2. Serving web pages and static content

3.3. Working with an external API

3.4. Managing logins and user sessions

3.5. Summary

sitemap