The application of node in the big front end

The use of node has been around for a long time, and the scope of use is also very wide. It seems that wherever there is a front end, there is node. So let's think about a question, what is node used for? This paper explains the problem from five major aspects.

We know that the emergence of node has given front-end development a new look after ajax, and has qualitatively improved development efficiency and performance. Induction has always been an important part of knowledge improvement. After referring to a lot of content, this article makes an entry-level summary of the application of node. After reading this article, I hope you can clearly understand the status and application of node in the big front end.

First look at a picture:

What node brings:

It can be seen from the figure that the application of node is very extensive, and the most commonly used ones are engineering, automation, npm

basic concept of node

1. JavaScript that does not run in the browser

2. A platform based on the Chrome JavaScript runtime

3. An event-driven I/O server-side JavaScript environment based on Google's V8 engine

Next, let's look at the application of Node.js in the big front end in detail.

broadly applied

js running on the non-browser side, including front-end environment construction, cloud construction, services, middleware, all have node.js application scenarios

application

1. Front-end tool chain level

Two, npm

3. Engineering related

Fourth, the front and rear ends are completely separated

5.  Server

1. Front-end tool chain

The specific use of babel, webpack, eslint, jest, etc. will not be discussed

Two, npm

1. Own command

Used to manage npm packages and execute node files

2. npm package

Features: The npm package as a whole is an abstraction of a class of code with common applications, including logic abstraction, component abstraction, and function abstraction

3. Engineering related

The establishment of the front-end environment is one of the most valuable applications of node.js in front-end development work. The emergence of node has brought front-end development from the era of slash-and-burn farming to the era of technology. Front-end engineering relies on the aforementioned webpack, gulp, babel, eslint, etc. In addition to client-side capabilities, the complete scaffolding system also includes automatic construction (such as jenkins) and command-line publishing functions

Develop desktop applications

Node.js makes it possible to develop desktop applications using js. Electron is currently a popular desktop application development tool. It combines nodejs and chromium, allowing users to call node.js functions and use almost all nodejs communities in the module.

At present, web applications are very popular, and desktop applications seem to be forgotten, but desktop applications also have certain advantages. For example, in the field of front-end engineering, desktop applications can be used as a unified GUI integration tool to make front-end engineering unified and simplified.

The meaning of front-end engineering

Fourth, the front and rear ends are completely separated

1. The front-end application is separated from the server-side code and deployed independently on the service provided by node.js

There are two rendering methods, one is conventional rendering, which generates html code in the browser;

The other is to use server-side rendering (ssr), which is similar to the way java generates html code before, but the current ssr has nothing to do with the real server, ssr is the way to render on the node side

2. Full-stack development based on large-scale projects

On the basis of the independent deployment of the front-end, logical codes such as data processing, interface proxy, and terminal adaptation are added to the node side, which greatly enhances the scalability and performance of the front-end. Common full-stack frameworks include egg, midway, etc.

The necessity of complete separation of front and rear ends

1. In the development process, some responsibilities are not clearly divided. The separation of front and back ends means that the front end no longer depends on the back end. The back end can focus on the model layer, and the front end can focus on the view and controller

2. In web performance optimization, the optimization work that the front-end can do has great limitations. Many optimizations must be completed on the basis of coordination with the back-end. Node.js is used as the middle layer, so that the front-end has enough optimization decision

3. The front-end can be based on business, adjust the front-end architecture, and integrate different technology stacks

Applicability of complete separation of front and rear ends

It is suitable for teams with certain technical support, and cannot be separated for the sake of separation

Front-end independent deployment extension

5. Node as the server

Node和serverless

Serverless began to emerge in China in 2019 and has not yet been applied on a large scale, but serverless is an inevitable trend.

As a new type of Internet architecture, it has directly or indirectly promoted the development of cloud computing. From AWS Lambda to Alibaba Cloud Function Computing, Serverless has been singing all the way. At the same time, serverless-based lightweight computing has begun to enter the cloud computing stage.

The core of Serverless is faas, function as a service, which solves the problems and pain points of traditional BFF, such as high resource cost, high operation and maintenance cost, high development cost, difficulty in adapting to fast changing requirements, etc., allowing developers to focus more on business logic, and other underlying Resources and operation and maintenance work have been fully encapsulated.

Node implements serverless

Use the Serverless framework to build a FaaS environment. The ServerLess framework is a CLI tool written in Node.js. Developers can deploy a complete and available Serverless application architecture without paying attention to the underlying resources.

Afterwards, developers only need to write related functions according to the business and deploy them on the cloud computing platform.

Platforms already using serverLess

Summarize:

Guess you like

Origin blog.csdn.net/qdmoment/article/details/105206270