NodeJS

Express 103: Routes and Controllers

NodeJS Course

Introduction

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.

Lesson overview

This section contains a general overview of topics that you will learn in this lesson.

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

Assignment

  1. Complete part 4 of the MDN Express tutorial.

Knowledge check

This section contains questions for you to check your understanding of this lesson. If you’re having trouble answering the questions below on your own, review the material above to find the answer.

Additional resources

This section contains helpful links to related content. It isn’t required, so consider it supplemental.

  • It looks like this lesson doesn’t have any additional resources yet. Help us expand this section by contributing to our curriculum.

Support us!

The Odin Project is funded by the community. Join us in empowering learners around the globe by supporting The Odin Project!