Home/Tutorials/Express/Middleware Basics

0 of 3 saved

Express5 min read

Middleware Basics

Read this chapter, write the program on this page, then pass a short check to open the next one.

Functions in the pipeline.

Middleware Basics

Middleware is (req, res, next) => {}. It can log, parse JSON, check auth, then call next(). Order matters.

  • express.json() parses JSON bodies.
  • Stop the chain by sending a response.
  • Shared logic belongs in middleware or helpers.
console.log("middleware-next");

After you read this chapter, use Write (when available) and Quiz on this page to lock it in.