Node.js · Junior · Question 61 of 75
What is middleware in Express?
- 1A database layer between Express and SQL
- 2A special type of route for static files
- ✓Correct answer: A function
(req, res, next)that runs during request handling and can changereq/res, end the response or callnext()
Explanation
Middleware runs in the order you register it. Typical uses: parsing the body, logging, authentication, CORS. Forgetting both next() and a response leaves the request hanging.