Middlewares are set of filters which every request to the web server has to go through. Node.js enables the creation of web server on the fly, all the requests which are received by the web server are first filtered by stack of filters, this is a very helpful feature, each filter performs a specific task like session handling, error handling, form field handling, logging etc
Node.Js Express framework’s Middleware are one of the useful feature which has simplified the development process.
How we stack our middlewares is important as certain tasks needs to be executed before others are done.
A very useful filter here is the cookie parser filter, this needs to be run before session handler middleware is invoked.
Error handling middleware should be invoked in the last which means if everything fails then do this gracefully.
Most of the common middleware we use are static middleware to handle the images other digital assets.
Another important area of middleware are the Connect middlewares. These are commonly used to address the regular web application pain points
bodyParser: Helpful in packing form fields submitted from HTML form.
morgan: Very popular for debugging and logging.
cookieParser: For sending and receiving cookies
Similar to the above there are many middlewares which simplify the development process.
Node.js can be learned from experts, for Node.js training in hyderabad contact here