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:
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsNotes
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: Express.js Deep API Reference. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-0781-9_2
Download citation
DOI: https://doi.org/10.1007/978-1-4842-0781-9_2
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-0782-6
Online ISBN: 978-1-4842-0781-9
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books