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.
Click to load comments...