What is Express JS middleware and how does it work?

I know I’m jumping ahead. I have a bunch of React posts to write before I should really be sharing Node/Express posts, but today is my first back-end sprint challenge at Lambda and it will focus on what we’ve learned about Node.JS & Express.JS so far.

This is the best video I’ve seen about Express middleware. Zach Gollwitzer should be given a a medal for the clarity that he brings to explaining how middleware order and parameters work. The video assumes you have a basic understanding of boilerplate Node/Express and then goes into middleware with a magnifying glass.

Here’s the table of contents from the description:

2:53 The standard Express callback function
5:51 Writing your first Express middleware
10:00 Route middleware vs. global middleware
15:34 Working with several middlewares in a single app
17:59 Error handler middleware
24:56 Modifying the req and res objects using middleware

Leave a comment