Chapter 9. Advanced Express
This chapter covers
- Implementing authentication
- URL routing
- Creating a REST API
- Handling errors
In this chapter, you’ll learn a number of advanced Express techniques that will enable you to take more advantage of the framework’s functionality.
To demonstrate these techniques, you’ll create a simple application that allows people to register and post public messages that are displayed, in reverse chronological order, for visitors to see. This type of application is known as a “shoutbox” application. Figure 9.1 shows the front and user registration pages. Figure 9.2 shows the login and post pages.
For this application, you’ll add logic to do the following:
- Authenticate users
- Implement validation and pagination
- Provide a public representational state transfer (REST) API to send and receive messages
Let’s dive in by leveraging Express for user authentication.
In this section you’ll start working on the shoutbox application by creating an authentication system for it from scratch. Within this section you’ll implement the following:
- Logic to store and authenticate registered users
- Registration functionality
- Login functionality
- Middleware to load user information, on request, for logged-in users