Home > Web Front-end > JS Tutorial > What does node.js do? Introduction to 10 application scenarios of node.js

What does node.js do? Introduction to 10 application scenarios of node.js

寻∝梦
Release: 2018-09-05 14:31:46
Original
8625 people have browsed it

This article mainly introduces the definition and description of node.js, as well as ten application scenarios of node.js, letting everyone know where node.js can be applied. Now let’s take a look at this article Article

First we need to know what node.js is?

1. What is Node.js (actually, it is about learning web server development)

1. It is a JS runtime environment (in simple terms, it can Parse and execute js code): not a language/library/framework

(1) JavaScript in Node.js does not have BOM or DOM, only EcmaScript (basic syntax), because the server does not operate the page

(2) In the Node javascript execution environment, some server-level operation APIs are provided for js (file reading and writing, building network services, network communication, http server, etc.)

2. Features: Use event-driven, non-blocking IO model (simply speaking, asynchronous), lightweight and efficient

3. Most JS-related packages are placed on npm

For example: With npm After that, one command can be issued to different libraries/frameworks (such as jquery), without having to go to the official website of each library/framework to download

2. What can Node.js do

1.Web server backend (node.js made of java and php can be used)

2.Command line tool

Note 1: BS programming of any server-side technology The models are all the same, regardless of language

Note 2: Node does not have html files, only .js files

Now count the 10 application scenarios of node.js:

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.

Usually 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 Socket.io

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

4Web 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, consistent DOM model, making parsing, manipulation, 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 type developed with Node.js and MongoDB Community software has an elegant interface, rich functions, small size and speed. 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. It is based on the modular idea of ​​nodejs and disperses functions into In each module, there is a connection between modules, and Bower is used to manage this connection 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 performs scheduled tasks in the simplest way. Later can run in Node and the browser.

The above is the introduction of node.js in this article and the introduction of ten application scenarios. Students who want to learn node.js can go to the PHP Chinese websiteNode.js Learning Manual

[Editor’s Recommendation]

How to set up the html search box? Examples of how to use the input tag in the html search box

html How to use the base tag? Summary of usage of html base tag

The above is the detailed content of What does node.js do? Introduction to 10 application scenarios of node.js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template