Lecture 11,12 Express
Lecture 11,12 Express
7 directories, 9 files
WEB TECHNOLOGIES AND PROGRAMMING (BY: HUMAIRA WAQAS) 4
EXPRESS - MIDDLEWARE
Middleware
Functions that have access to the request object (req), the response
object (res), and the next middleware function in the application’s
request-response cycle.
Middleware functions can perform the following tasks:
• Execute any code.
• Make changes to the request and the response objects.
• Call the next middleware function in the stack.
• End the request-response cycle.
WEB TECHNOLOGIES AND PROGRAMMING (BY: HUMAIRA WAQAS) 5
EXPRESS - MIDDLEWARE
• When a request is received by Express, each middleware that matches the request is run in the
order it is initialized until there is a terminating action (like a response being sent).
• If an error occurs, all middleware that is meant to handle errors will be called in order until one of
them does not call the next() function call.