5 Express Middleware Libraries Every Developer Should Know!
1. Cookie-parser — Parse Cookies
Cookie-parser is a middleware that transfers cookies with client requests.
Cookie-parser uses the req.cookies property to access Cookie data. After parsing, the req.cookies object holds cookies sent by request in JSON format.
It is capable of parsing both unsigned and signed cookies.
Features of Cookie-parser
2.Passport — Access to Wide Range of Authentication Mechanisms
Passport is a simple unrobustive authentication middleware for Node.js.
It consists of a comprehensive set of authentication mechanisms known as "strategies." Those strategies support authentication using either a username and password or Facebook, Twitter, and more. Passport allows the developers to make application-level decisions and choose the best strategy maximizing its flexibility.
Features of Passport
3. Morgan— Log HTTP Requests and Errors
Morgan is an HTTP request logger middleware for Node.js typically used for Express apps.
It streamlines the process by generating logs for each API request and error. The best fact is that you can utilize a predefined format or design one from scratch, depending on your requirements.
Features of Morgan
Morgan has over 12.88 million NPM downloads per month and 6.8K GitHub stars.
领英推荐
4. CORS — Allow or Restrict Requested Resources on a Web Server
CORS is a node.js package that provides a Connect/Express middleware for enabling CORS with a variety of options.
CORS stands for Cross-Origin Resource Sharing. Without prior consent, it prevents other websites or domains from accessing your web resources directly from the browser.
Features of CORS
CORS has over 6 million NPM downloads per week and 5.2K GitHub ratings.
5. Helmet — Increase HTTP Header Security
Helmet helps you secure your Express apps by setting various HTTP headers.
It is a quick and straightforward way to create an additional layer of security by switching from Express default headers to more standard ones.
Features of Helmet
Helmet has over 1 million NPM downloads per week and 8.6K GitHub ratings.
#dev #mern #nodejs #node