Table of Contents
Restify##restify is a REST application framework based on Nodejs, supporting server and client . Restify is more focused on REST services than express, removing the template, render and other functions in express. At the same time, it strengthens the use of REST protocol, versioning support, and HTTP exception handling. " >Rest Development- Restify##restify is a REST application framework based on Nodejs, supporting server and client . Restify is more focused on REST services than express, removing the template, render and other functions in express. At the same time, it strengthens the use of REST protocol, versioning support, and HTTP exception handling.
Toolkit
Unit Test
Home Web Front-end JS Tutorial Summarize some modules commonly used in Nodejs development

Summarize some modules commonly used in Nodejs development

Apr 15, 2021 am 10:12 AM
node module

This article will introduce to you some modules commonly used in Nodejs development. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

Summarize some modules commonly used in Nodejs development

Collects some modules commonly used in NodeJS development.

MVC Framework - Express

##Express is a lightweight and flexible Nodejs web application framework that can be quickly built website. The Express framework is built on the built-in Http module of Nodejs and repackages the Http module to implement the function of Web request processing. 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. [Related recommendation: "

nodejs Tutorial"]

Koa is another work of T.J. It is known as the next generation NodeJS web framework. Using koa to write web applications, by combining different generators, you can avoid repeated and cumbersome callback function nesting, and greatly improve the efficiency of common error handling. Koa does not bind any middleware in the kernel method. It only provides a lightweight and elegant function library that makes writing web applications easy. It should be noted that koa relies on the Node environment that supports generators. To be precise, it is the environment of node >= 0.11.9. After the installation is complete, you should make sure to run the program using $ node app.js --harmony or (--harmony-generators) i.e., harmony mode. Personally, I feel that if it is a formal product, it is more reliable to use Express.

Rest Development- Restify##restify is a REST application framework based on Nodejs, supporting server and client . Restify is more focused on REST services than express, removing the template, render and other functions in express. At the same time, it strengthens the use of REST protocol, 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 and reusable application logic rather than building architecture. It has built-in input validation, caching, authentication and other functions commonly used in web application development. It is also a good choice for developing rest code.

Front-end template -

EJS##EJS is a powerful and easy-to-use front-end template. Express is very suitable for EJS The support is relatively good, and its syntax is closer to how front-end developers use it. In addition, the more famous front-end template is Jade

, which was developed by the same author as Express. Express uses the Jade template by default, but its syntax is closer to the syntax of the back-end language, and there are many front-end developers. It's hard to get used to, but it's really powerful.

Database driver -

Mongoose##MongoDB and NodeJS should be the best partners, and Mongoose is the object model tool of MongoDB. Through the Mongoose framework, you can perform very convenient operations to access MongoDB. Of course, if you have very high performance requirements, you can also consider using

mongodb

, which has relatively few functions and is relatively low-level. In fact, Mongoose is built on it. Others: redis,

mysql

. Web Socket -

Socket.IOOne of the main advantages of NodeJS is high concurrency, so NodeJS is Web Socket The ideal choice for servers, and Socket.IO is the best choice for Socket modules, which can be used to build chat rooms, customer service systems, etc. Socket.IO not only provides server-side code, but also provides front-end JS code, which makes Web Socket development very convenient. At the same time, it is compatible with browsers that do not support Web Socket.

Log management- Log4js

is similar to log4j in JAVA, with functions such as colored console logging and the ability to set output levels. Simple and easy to use, enough to use if there are no complex requirements. winston is a log module with more powerful and complex functions. It is relatively popular. Those who are pursuing functions can take a look at this module.

HTTP call Request

can be understood as a simplified CURL module that establishes various HTTP requests and supports authorization Verification, in fact, there are still many functions, which basically meet most needs. Currently among the top NPM modules.

Asynchronous process control - Async

##The large number of asynchronous callback nesting in NodeJS is estimated to give many people a headache, especially When multiple asynchronous functions require a certain calling sequence, the code gets out of control. Async can solve these problems very well. It can synchronize the asynchronous process.

Q is another very good choice, it implements the promises interface.

Deployment- forever

#forever

can be seen as a nodejs daemon. Able to start, stop, and restart our app application, run stably, support high concurrency, simple start/stop commands, support hot deployment, restart after downtime, monitoring interface and logs, and cluster environment. pm2 is a process manager for Node applications with load balancing function. When you want your standalone code to utilize all CPUs on all servers and keep the process alive, 0 second reloads. If you want to solve the NodeJS server management problem from the operating system level, you can refer to:

Linux system service upstart

Of course you can use

supervisor during development

Start the service, which can monitor files and automatically restart the service when there are file updates. In fact, Forever also has this function.

Project Management

grunt

is an automated build tool for tasks that need to be repeated over and over again, such as minification, compilation, and units. For testing, linting, etc., automated tools can reduce your labor and simplify your work. When you configure the task correctly, the task runner will automatically complete most of the boring work for you or your team. And it has a large number of plug-ins available. I mainly use it for front-end automated processing.

bower

is another open source project of Twitter, developed using nodejs and used for web package management. As a js dependency management tool, it provides an ideal package management method, using some ideas of npm, to provide us with a comfortable development environment.

yeoman

was developed by Google's team in collaboration with a team of external contributors. Its goal is to use Grunt (a command line tool for automating development tasks) and Bower (an HTML, A package manager for front-end resources such as CSS, Javascript, and images) that creates an easy-to-use workflow for developers. The purpose of Yeoman is not only to establish workflows for new projects, but also to solve many serious problems faced by front-end development, such as scattered dependencies.

Scheduled tasks -

Cron##cron is a small scheduled task management module that can satisfy most of our needs Requirements, it supports standard cron patterns, and you can easily get started if you are familiar with the syntax of Linux cron tab.

Another well-known and powerful timing module is

Later

. It can be used for those with higher functional requirements. The disadvantage of later is that it is a bit complicated. Unlike cron, it only needs to be used. Will use it.

Toolkit

underscore is a JS tool library that mainly provides some basic tool functions for arrays, objects, functions, etc., which can be used in the browser at the same time and run in NodeJS environment. Recommended for use in every project.

moment is a date tool library that mainly provides parsing, verification, operation and formatting of dates. If you need to perform more operations or more complex operations on dates, Then it is a good choice, after all, the Date function that comes with JS is too weak.

Connect is a collection of middleware, including log, session, cookie, body parser, etc. It does a lot of basic work related to HTTP, and the Express framework relies on it. carrying out work.

Unit Test

Mocha,Karma,Jasmine.

For more programming related knowledge, please visit: Programming Video! !

The above is the detailed content of Summarize some modules commonly used in Nodejs development. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

WLAN expansion module has stopped [fix] WLAN expansion module has stopped [fix] Feb 19, 2024 pm 02:18 PM

If there is a problem with the WLAN expansion module on your Windows computer, it may cause you to be disconnected from the Internet. This situation is often frustrating, but fortunately, this article provides some simple suggestions that can help you solve this problem and get your wireless connection working properly again. Fix WLAN Extensibility Module Has Stopped If the WLAN Extensibility Module has stopped working on your Windows computer, follow these suggestions to fix it: Run the Network and Internet Troubleshooter to disable and re-enable wireless network connections Restart the WLAN Autoconfiguration Service Modify Power Options Modify Advanced Power Settings Reinstall Network Adapter Driver Run Some Network Commands Now, let’s look at it in detail

WLAN extensibility module cannot start WLAN extensibility module cannot start Feb 19, 2024 pm 05:09 PM

This article details methods to resolve event ID10000, which indicates that the Wireless LAN expansion module cannot start. This error may appear in the event log of Windows 11/10 PC. The WLAN extensibility module is a component of Windows that allows independent hardware vendors (IHVs) and independent software vendors (ISVs) to provide users with customized wireless network features and functionality. It extends the capabilities of native Windows network components by adding Windows default functionality. The WLAN extensibility module is started as part of initialization when the operating system loads network components. If the Wireless LAN Expansion Module encounters a problem and cannot start, you may see an error message in the event viewer log.

How to use express to handle file upload in node project How to use express to handle file upload in node project Mar 28, 2023 pm 07:28 PM

How to handle file upload? The following article will introduce to you how to use express to handle file uploads in the node project. I hope it will be helpful to you!

Python commonly used standard libraries and third-party libraries 2-sys module Python commonly used standard libraries and third-party libraries 2-sys module Apr 10, 2023 pm 02:56 PM

1. Introduction to the sys module The os module introduced earlier is mainly for the operating system, while the sys module in this article is mainly for the Python interpreter. The sys module is a module that comes with Python. It is an interface for interacting with the Python interpreter. The sys module provides many functions and variables to deal with different parts of the Python runtime environment. 2. Commonly used methods of the sys module. You can check which methods are included in the sys module through the dir() method: import sys print(dir(sys))1.sys.argv-Get the command line parameters sys.argv is used to implement the command from outside the program. The program is passed parameters and it is able to obtain the command line parameter column

Python programming: Detailed explanation of the key points of using named tuples Python programming: Detailed explanation of the key points of using named tuples Apr 11, 2023 pm 09:22 PM

Preface This article continues to introduce the Python collection module. This time it mainly introduces the named tuples in it, that is, the use of namedtuple. Without further ado, let’s get started – remember to like, follow and forward~ ^_^Creating named tuples The named tuple class namedTuples in the Python collection gives meaning to each position in the tuple and enhances the readability of the code Sexual and descriptive. They can be used anywhere regular tuples are used, and add the ability to access fields by name rather than positional index. It comes from the Python built-in module collections. The general syntax used is: import collections XxNamedT

An in-depth analysis of Node's process management tool 'pm2” An in-depth analysis of Node's process management tool 'pm2” Apr 03, 2023 pm 06:02 PM

This article will share with you Node's process management tool "pm2", and talk about why pm2 is needed, how to install and use pm2, I hope it will be helpful to everyone!

Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node? Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node? Mar 05, 2025 pm 05:57 PM

Detailed explanation and installation guide for PiNetwork nodes This article will introduce the PiNetwork ecosystem in detail - Pi nodes, a key role in the PiNetwork ecosystem, and provide complete steps for installation and configuration. After the launch of the PiNetwork blockchain test network, Pi nodes have become an important part of many pioneers actively participating in the testing, preparing for the upcoming main network release. If you don’t know PiNetwork yet, please refer to what is Picoin? What is the price for listing? Pi usage, mining and security analysis. What is PiNetwork? The PiNetwork project started in 2019 and owns its exclusive cryptocurrency Pi Coin. The project aims to create a one that everyone can participate

How to use DateTime in Python How to use DateTime in Python Apr 19, 2023 pm 11:55 PM

All data are automatically assigned a "DOB" (Date of Birth) at the beginning. Therefore, it is inevitable to encounter date and time data when processing data at some point. This tutorial will take you through the datetime module in Python and using some peripheral libraries such as pandas and pytz. In Python, anything related to date and time is handled by the datetime module, which further divides the module into 5 different classes. Classes are simply data types that correspond to objects. The following figure summarizes the 5 datetime classes in Python along with commonly used attributes and examples. 3 useful snippets 1. Convert string to datetime format, maybe using datet

See all articles