Be the first user to complete this post
|
Add to List |
Understanding expressjs middleware with a visual example
function(req, res, next){
// Your business logic goes here
}
For example, you could implement a simple request logger by defining middleware function that does just that.
function(req, res, next){
// Basic logging for all the routes
console.log(req.method + ':' + req.originalUrl);
next();
};
Also Read:
- Installing, Listing and Uninstalling packages using npm
- Send email using nodejs and express in 5 simple steps
- Understanding routers in express 4.0 - Visually
- What is npm shrinkwrap and when is it needed
- Creating a simple event emitter using nodejs