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, a controller is, as you’ll see the code that sits between the models and the views and determines which view is going to be shown and 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 catalog route module.
  • Describe approaches for structuring routes and controllers.
  • Set up URL endpoints.

Assignment

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

Have a question?

Chat with our friendly Odin community in our Discord chatrooms!

Open Discord