Express 103: Routes and Controllers

The next step in the MDN express tutorial sets up all the routes and controllers you’re going to need when creating the Library project. This project is designed using the MVC (Model, View, Controller) architecture. In a previous step you set up all the Models (or Database Objects) and in the next step you’ll be setting up several different views.

If you remember from our earlier lessons, the controller is the code that sits between the models and the views. It determines which view is going to be shown, as well as which information is going to populate that view. In this lesson, you will copy and paste quite a bit of repetitive code to get the controllers and routes set up, but be sure to read everything in between them! There is a lot of useful information therein.

Learning Outcomes

By the end of this lesson, you should be able to do the following:

  • Create simple routes.
  • Create route-handler callback functions.
  • Create a catalog route module.
  • Describe approaches for structuring routes and controllers.
  • Set up URL endpoints.

Assignment

  1. Continue where we left off with part 4 of the Express tutorial
Improve this lesson on GitHub

Have a question?

Chat with our friendly Odin community in our Discord chatrooms!

Open Discord