Complete the code to add a middleware function that logs every request.
app.use(function(req, res, [1]) { console.log('Request received'); [1](); });
next causes the middleware chain to break.The next parameter is used to pass control to the next middleware function.
Complete the code to create a middleware that handles JSON body parsing.
app.use(express.[1]());urlencoded instead of json when expecting JSON data.The express.json() middleware parses incoming JSON requests.
Fix the error in the middleware that does not call the next function.
app.use(function(req, res, [1]) { res.send('Hello'); });
next() causes the request to hang.Middleware must call next() to pass control unless it ends the response.
Fill both blanks to create a middleware that checks if user is authenticated and calls next if true.
app.use(function(req, res, [1]) { if(req.user) { [2](); } else { res.status(401).send('Unauthorized'); } });
next().The middleware uses next to continue if the user is authenticated.
Fill all three blanks to create a middleware that logs method and URL, then calls next.
app.use(function(req, res, [1]) { console.log(req.[2], req.[3]); [1](); });
next().This middleware logs the HTTP method and URL, then calls next() to continue.
