Home > Web Front-end > Front-end Q&A > What nodejs can do

What nodejs can do

藏色散人
Release: 2021-11-22 13:38:56
Original
25520 people have browsed it

What nodejs can do: 1. Realize full-stack development for programmers; 2. Unify public class libraries and standardize codes; 3. Asynchronous programming; 4. Process IO-intensive applications; 5. Build complex System; 6. Implement a monitoring system for the memory stack, etc.

What nodejs can do

The operating environment of this article: Windows7 system, nodejs10.16.2, Dell G3 computer.

nodejs Introduction:

Node.js is a JavaScript running environment based on the Chrome V8 engine. Node.js uses an event-driven, non-blocking I/O model, making it lightweight and efficient. Node.js's package manager npm is the world's largest open source library ecosystem.

What can nodejs do?

1. Nodejs is based on Javascript language, so there is no need to learn an unfamiliar language separately, thus lowering the learning threshold. At the same time, the Javascript language is crucial in Web front-end development, especially HTML5 applications must use it. Therefore, the unified language of the front and backend can not only realize the full-stack development of programmers, but also unify public class libraries and standardize codes. Based on this alone, Nodejs has won the favor of the market.

2. Nodejs did not re-develop the runtime environment, but chose V8, the fastest browser kernel currently, as the execution engine to ensure the performance and stability of Nodejs.

3. The development of Nodejs is very efficient and the code is simple. It is proud of the single-thread mechanism of Nodejs. Another feature of Nodejs, asynchronous programming, gives Nodejs a clear advantage in handling IO-intensive applications. Personally, I feel that using Nodejs for web development is 10 times more efficient than Java and simpler than PHP code.

4. The Nodejs community is growing. Not only is the number of packages increasing rapidly, but the quality of the packages is also significantly better than that of other languages. Many star-level packages are simple and smart, designed for developers' usage habits. The toolkits I use most, such as socket.io, moment.js, underscore.js, async.js, express.js, bower.js, grunt.js, forever.js..., are really changing my previous programming habits. .

Of course, in addition to my reasons for using Nodejs, many companies also have their own reasons for using it.

The reasons why ebay chose Nodejs can be summarized into the following four points:

Dynamic language: very high development efficiency and the ability to build complex systems, such as http:/ /ql.io.

Performance and I/O load: Nodejs solves IO-intensive problems very well through asynchronous IO.

Memory overhead of connections: Each Node.js process can support more than 120,000 active connections, and each connection consumes approximately 2K of memory.

Operation: Implemented the Nodejs monitoring system for the memory stack.

15 Nodejs application scenarios

We already have a preliminary understanding of Nodejs, let’s take a look at the application scenarios of Nodejs.

1 Web development: Express EJS Mongoose/MySQL

express is a lightweight and flexible Nodejs web application framework that can quickly build a 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.

ejs is an embedded Javascript template engine that generates HTML code through compilation.

mongoose is the object model tool of MongoDB. Through the Mongoose framework, you can access MongoDB.

mysql is a communication API that connects to the MySQL database and can be used to access MySQL.

Normally using Nodejs for web development requires the use of three frameworks, just like SSH in Java.

2 REST development: Restify

restify is a REST application framework based on Nodejs, supporting server and client. Restify focuses more 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.

3 Web Chat Room (IM): Express http://Socket.io

socket.io is a software based on the Nodejs architecture and supports the websocket protocol for real-time communication. Bag. Socket.io provides a complete package for building real-time applications across browsers. Socket.io is completely implemented by JavaScript.

4 Web crawler: Cheerio/Request

cheerio is a fast, flexible and encapsulating jQuery core function toolkit specially customized for the server. Cheerio includes a subset of core jQuery, stripping away all DOM inconsistencies and browser incompatibilities from the jQuery library, revealing its truly elegant API. Cheerio works on a very simple and consistent DOM model, making parsing, operation, and rendering incredibly efficient. Basic end-to-end benchmarks show that Cheerio is approximately eight times (8x) faster than JSDOM. Cheerio encapsulates the @FB55 compatible htmlparser and can parse almost any HTML and XML document.

5 Web blog: Hexo

Hexo is a simple, lightweight, static blog framework based on Node. Through Hexo, we can quickly create our own blog, which can be completed with only a few commands.

When released, Hexo can be deployed on your own Node server or on github. For individual users, deploying on GitHub has many benefits. It can not only save the cost of servers, but also reduce the troubles of various system operation and maintenance (system management, backup, network). Therefore, personal sites based on github are beginning to become popular...

6 Web Forum: nodeclub

Node Club is a new community software developed with Node.js and MongoDB, with an elegant interface and powerful functions Rich, compact and fast, it has been used in the Node.js Chinese technical community CNode, but you can use it to build your own community.

7 Web Slideshow: Cleaver

Cleaver can generate presentations based on Markdown. If you already have a Markdown document, you can create a slideshow in 30 seconds. Cleaver is a tool for Hackers.

8 Front-end package management platform: bower.js

Bower is a package management tool launched by twitter. Based on the modular idea of ​​nodejs, the functions are dispersed into various modules, so that the modules and There is a relationship between modules, and Bower is used to manage this relationship between modules.

9 OAuth authentication: Passport

The Passport project is an authentication middleware based on Nodejs. The purpose of Passport is only for "login authentication". Therefore, the code is clean, easy to maintain, and can be easily integrated into other applications. Web applications generally have two forms of login authentication: username and password authentication login, and OAuth authentication login. Passport can configure different authentication mechanisms according to the characteristics of the application. This article will introduce the authentication login of user name and password.

10 Scheduled task tool: later

Later is a tool library based on Nodejs that executes scheduled tasks in the simplest way. Later can run in Node and the browser.

11 Browser environment tools: browserify

The emergence of Browserify allows Nodejs modules to run in the browser, use the require() syntax format to organize the front-end code, and load npm modules. In the browser, the code compiled by calling browserify is also written in the

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template