Nodejs Common Module Collection

Source: Internet
Author: User

Some of the modules commonly used in NODEJS development are collected.

MVC Framework-Express

Express is a lightweight and flexible Nodejs Web application framework that allows you to build websites quickly. The Express framework is built on the Nodejs built-in HTTP module, and re-wraps the HTTP module to the actual Web request processing functionality. It supports a variety of front-end templates such as Jade, EJS, etc. It is the work of T.J, but it has been maintained by other teams.

KOA is another t.j of the great God, claiming to be the next Generation Nodejs Web framework. Using KOA to write Web applications, by combining different generator, you can eliminate the duplication of tedious callback function nesting and greatly improve the efficiency of common error handling. Koa does not bind any middleware in the kernel method, it simply provides a lightweight and elegant library of functions, making it handy to write WEB applications. It is important to note thatKOA relies on the node environment that supports generator, which is exactly the context of node >= 0.11.9. After the installation is complete, be sure to run the program using the node App.js--harmony or (--harmony-generators), which is Harmony mode. . Personally feel that if it is a formal product or express more reliable.

Rest Development-Restify

Restify is a Nodejs-based rest application framework that supports both server-side and clients. Restify is more focused on rest services than Express, removing the template and render features in Express, while reinforcing the rest protocol usage, versioning support, and HTTP exception handling.

Hapi is a rich framework for building node. JS-based applications and services, allowing developers to focus on portable reusable application logic rather than building architectures. Built-in input validation, caching, authentication, and other common features for WEB application development are also a good choice for developing rest code.

Front-end templates-EJS

Ejs is a powerful and easy-to-use front-end template, and Express has a better support for Ejs, and its syntax is closer to the way front-end developers use it. Another well-known front-end template is Jade, which was developed by the same author as Express, and the default is the Jade template, but its syntax is closer to the syntax of the back-end language, the front-end developers are often difficult to adapt, but it is really powerful.

Database Driver-Mongoose

MongoDB and Nodejs should be the best partner, while Mongoose is a MongoDB object Model tool that allows for very convenient access to MONGODB operations through the Mongoose framework. Of course, if you are very high performance requirements, you can also consider using MongoDB, it has relatively few functions, compared to some of the lower, in fact, Mongoose is based on it built.

Others: Redis,mysql.

Web Socket-socket.io

One of the main advantages of Nodejs is high concurrency, so Nodejs is the ideal choice for a Web socket server, and Socket.io is the perfect choice for a socket module that can be used to build chat rooms, customer service systems, and more. Socket.io not only provides the server-side code, but also provides the front-end JS code, can be very convenient for web socket development, and it is compatible with those who do not support the web socket browser.

Log Management-LOG4JS

Similar to the log4j in Java, with coloured console logging, you can set the output level and other functions, easy to use, if there is no complex requirements to be used enough. Winston is a more powerful and more complex log module, the popularity of high, the pursuit of the function can look at this module.

HTTP Call Request

Can be understood as a simplified curl module, the establishment of various HTTP requests, support authorization verification, in fact, the function is very much, basically meet the overwhelming majority of demand. There are currently several top-ranked NPM modules.

Asynchronous Process Control-Async

The large number of asynchronous callback nesting estimates in Nodejs make a lot of headaches, especially when multiple asynchronous functions require a certain sequence of calls to make the code out of control, and async can solve these problems very well, which can synchronize the asynchronous process. Q is another very good choice, it is the implementation of the promises interface.

Deployment-Forever

Forever can be seen as a Nodejs daemon that can start, stop, restart our app, run stably, support high concurrency, start/stop commands simple, support hot deployment, downtime restart, monitor interface and log, cluster environment. The PM2 is a process manager for a node app with load-balancing capabilities. When you are going to take your standalone code all the CPUs on the server and make sure that the process is always alive, 0 seconds of overloading.

If you want to address Nodejs server management issues from the operating system level, you can refer to: Linux system services Upstart

Of course, the development can use the Supervisor startup service, it can monitor files, when there is a file update automatically restart the service, in fact, forever also have this feature.

Project Management

Grunt is an automated build tool for tasks that require repetitive repetition, such as compression (Minification), compilation, unit testing, linting, and so on, and automated tools that can ease your labor and simplify your work. When you properly configure the task, the task runner will automatically help you or your team to do most of the boring work. And it has a large number of plugins that can be used. I mainly use it as the front end of the automated processing work.

Bower is another open source project for Twitter, developed using Nodejs for Web package management. As a JS-dependent management tool, provides an ideal package management method, with the help of NPM ideas, to provide us with a comfortable development environment.

Yeoman was developed by a team of Google and external contributors, with the goal of grunt (a command-line tool for developing task Automation) and Bower (an HTML, CSS, Package Manager for front-end resources such as JavaScript and images creates an easy-to-use workflow for developers. The purpose of Yeoman is not only to build workflows for new projects, but also to address the many serious problems faced by front-end development, such as fragmented dependencies.

Scheduled Tasks-Cron

Cron is a small scheduled task management module that can meet most of our needs, it supports standard cron patterns, and the syntax of Linux cron tab is easy to get started with.

Another famous and powerful timing module is later, for the functional requirements of a relatively high use it, the shortcomings of later is a bit complex, not like Cron as long as it will be used.

Tool Pack

Underscore is a JS tool library that provides basic tool functions such as arrays, objects, functions, and so on, which can be run both in the browser and in the NODEJS environment. Recommended for use in each project.

Moment is a date tool library, mainly provides the resolution of the date, validation, operation and formatting, if you need to do more on the date or more complex operation, then it is a good choice, after all, JS comes with the date function is too weak.

Connect is a collection of middleware, including logs, sessions, cookies, body parser, etc., it does a lot of HTTP-related basic work, the express framework relies on it to work.

Unit Test

Mocha,karma,jasmine.

Reference documents
    • Start from scratch Nodejs series articles
    • node. JS Learning Roadmap
    • NPM official website

Nodejs Common Module Collection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.