5 Essential NPM Packages You Must Know
Every scalable project should meet some criteria. So I am going to describe the best practices.
array is mandatory in every system.
A system without a
logger is a headache, and it is almost impossible to maintain if there any error occurs.
We also need
middleware and one last thing is automated
Every point I mentioned is mandatory for large/small systems. Sometimes we do it from scratch, but I think this is a waste of time. Some npm packages have great support with these features, and it is
easy to use.
1. Moment — Time manipulation
I think handling time management (timezone, date, month, format, etc.)is the most common and hassle in a system. The Moment is one of the most stable & maintained time manipulation library. The whole collection of libraries, created to solve the issues of formatting, parsing, converting, and, generally, working with different forms of time,
Moment.js is the one that has seen the widest adoption. Here is the reference.
2. Winston — logger tool
For reporting, the system should have a logger and
winston is better for this. Winston is very powerful and easy to use. Logger helps to debug from the previous report. Store log file as JSON is standard, and I think this is helpful because JSON is more flexible to go through the script for finding the desired report. Just go to the link and have a look.
The most popular and widely used library for playing with array loadash is popular. A huge number of projects and library depends on it.
- Iterating arrays, objects, & strings
- Manipulating & testing values
- Creating composite functions
Mocha is the most powerful testing tool in node.js widely used for test. It makes asynchronous testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting while mapping uncaught exceptions to the correct test cases. Just pass your input and desired value and it will return you the result.
Morgan is the most popular HTTP request logger middleware for node.js.
Morgan functions take 3 arguments token, req, and res, where a token is an object with all defined tokens, req is the HTTP request, and res is the response. The function is expected to return a string that will be the log line, undefined, or null to skip logging.
HTTP request logger middleware for node.js Named after Dexter, a show you should not watch until completion. Create a…
Obviously, you need all of these in your day-to-day life if you are a programmer, and having these concepts can help you to release your pain.
Have a great day!