Abstract
Middleware is an amazingly useful pattern that allows developers to reuse code within their applications and even share it with others in the form of NPM modules. The essential definition of middleware is a function with three arguments: request (or req), response (res), and next. If you’re writing your own middleware, you can use arbitrary names for arguments, but it’s better to stick to the common naming convention. Here’s an example of how to define your own middleware:
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2014 Azat Mardan
About this chapter
Cite this chapter
Mardan, A. (2014). Working with Middleware. In: Pro Express.js. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-0037-7_4
Download citation
DOI: https://doi.org/10.1007/978-1-4842-0037-7_4
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-0038-4
Online ISBN: 978-1-4842-0037-7
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books