The video for this lesson is currently being updated, please read the transcript instead.

Auth middleware

Let's now abstract the authentication code from the GET /users endpoint so it can be used with any route we create.

We're going to do this by creating our own custom middleware.

You'll recall that middleware is a hook into your request/response loop, that can transform the request or response objects. For example, we added the body-parser middleware to Express which transforms the request body from a stream to a JavaScript object.

To view the complete lesson you'll need to login or join this course.


Click to load comments...