Nodejs, please advise on the way to learn

  node.js, question

I have heard nodejs a long time ago, but unfortunately I have not tried it all the time. I plan to get started recently.

Because his second weapon has always been python before, of course the first is php.2333333

Nodejs seem to be very popular with young people.
At the right moment, I haven’t studied js very systematically.
Just borrow nodejs to consolidate it

Here comes the problem.

one
Nodejs really have very strong attack power? Where is it reflected?
For example, python is often used for crawling

two
Also, what widely used framework recommendations does nodejs have?
I am studying for the sake of learning. I am most afraid of unexpected problems. The network has no solution.

Node was created because the author wanted to write a web server based on event-driven and non-blocking I/O, so its characteristic is based on event-driven and non-blocking I/O. Its disadvantage is that it is not easy to make full use of multi-core. I think the reason why it is so popular is that its core idea is relatively popular. Now node has a very good Chinese community cnode, of course stackoverflow is the first choice, js grammar is very simple, easy to use, and now node is very popular and has many libraries, so you can go to npm website if you have nothing to do.
About node’s Popular Modules:
Some modules commonly used in NodeJS development are collected.
MVC framework-Express

Express is a lightweight and flexible Nodejs Web application framework, which can quickly build websites. The Express framework is built on the built-in Http module of Nodejs and repackages the Http module, thus realizing the function of Web request processing. It supports a variety of front-end templates, such as Jade, EJS, etc. It is the work of great god t j, but it has been maintained by other teams.
Koa is another work by t.j. great god, which claims to be the next generation of NodeJS web framework. Using koa to write web applications, by combining different generator, it can avoid repeated tedious callback function nesting and greatly improve the efficiency of common error handling. Koa does not bind any middleware in kernel methods, it only provides a lightweight and elegant library of functions, making writing Web applications handy. It should be noted that koa relies on the Node environment supporting generator, specifically, the environment where node >= 0.11.9. After the installation is completed, make sure to use $ nodepap.js-harmony or (–harmony-generators), that is, harmony mode to run the program. Personally, I think it is more reliable to use Express in official products.

Rest development-Restify

Restify is a Nodejs-based REST application framework that supports both server and client. Restify is more focused on REST services than express, eliminating the functions of template, render in express, while strengthening the use of REST protocol, versioning support and HTTP exception handling.
Hapi is a rich framework for building applications and services based on Node.js, enabling developers to focus on portable and reusable application logic instead of building architectures. Built-in input validation, caching, authentication and other common functions for Web application development are also good choices for developing rest code.

Front End Template-EJS

EJS is a powerful and easy-to-use front-end template. Express supports EJS better and its syntax is closer to that of front end development personnel. In addition, the famous front-end template is Jade, which was developed by the same author as Express. Express uses Jade template by default, but its syntax is closer to that of the back-end language, which is difficult for front end development personnel to adapt to, but its function is really very powerful.

Database driver-Mongoose

MongoDB and NodeJS should be the best partners, and Mongoose is MongoDB’s object model tool. Through the Mongoose framework, it is very convenient 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 lower level. Actually Mongoose is built on it.
Others: redis, mysql.

Web Socket – Socket.IO

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

Log management-Log4js

Similar to log4j in JAVA, it has the functions of coloured console logging, setting output level, etc. it is simple and easy to use. if there is no complicated requirement, it is enough to use. Winston is a log module with more powerful and complicated functions. Its popularity is relatively high. Those who have pursuit of functions can look at this module.

HTTP call Request

It can be understood as a simplified CURL module that establishes various HTTP requests and supports authorization verification. In fact, it has many functions and basically meets most of the requirements. At present, it ranks in the top several NPM modules.

Asynchronous process control-Async

A large number of asynchronous callback nesting estimates in NodeJS make many people headache, especially when multiple asynchronous functions require a certain calling sequence, which makes the code out of control. Async can solve these problems very well, and it can synchronize asynchronous processes. Q is another very good choice. It implements the promises interface.

Deployment-forever

Forever can be seen as a nodejs daemon, which can start, stop and restart our app application. It runs stably, supports high concurrency, has simple start/stop commands, supports Hot deployment, downtime restart, monitors interface and logs, and clusters environment. Pm2 is a process manager of Node application with load balancing function. When you want to use your independent code with all Central Processor on all servers, and ensure that the process is always alive, the overload of 0 seconds.
If you want to solve the NodeJS server management problem from the operating system level, please refer to: Linux system service upstart
Of course, supervisor can be used to start the service during development. it can monitor files and restart the service automatically when files are updated. in fact, Forever also has this function.

Project management

Grunt is an automated building tool. For tasks that need to be repeated repeatedly, such as compression, compilation, unit testing, linting, etc., automated tools can reduce your labor and simplify your work. When you set up the task correctly, the task handler will automatically help you or your team finish most boring tasks. And it has a large number of plug-ins to use. I mainly use it for front-end automation.
Bower is another open source project of twitter, developed using nodejs for web package management. As a js-dependent management tool, it provides an ideal package management method and provides us with a comfortable development environment with the help of some ideas of npm.
Yeoman was developed by Google’s team and the team of external contributors. His goal is to create an easy-to-use workflow for developers through the packaging of Grunt (a command line tool for developing task automation) and Bower (a package manager for front-end resources such as HTML, CSS, Javascript and pictures). Yeoman’s aim is not only to establish workflow 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 timing task management module, which can meet most of our needs. It supports standard cron patterns and can be easily used if you are familiar with the syntax of linux cron tab.
Another well-known and powerful timing module is later. For those with high functional requirements, Later has the disadvantage of being a bit complicated, unlike cron, which can be used as long as it is used.

Tool kit

Underscore is a JS tool library, which mainly provides some basic tool functions such as arrays, objects, functions, etc. It can be run in browser and NodeJS environment at the same time. Recommended for each project.
Moment is a Date tool library, which mainly provides analysis, verification, operation and formatting of dates. If more or more complicated operations are needed on dates, it is a good choice. After all, JS’s own DATE function is too weak.
Connect is a collection of middleware, including log, session, cookie, body parser, etc. It has done a lot of basic work related to HTTP, and the Express framework relies on it for its work.

unit testing

Mocha,Karma,Jasmine。

I recommend Park Ling’s book “Nine Shallow and One Deep nodejs”, (ps: Alias for Deep nodejs)
Finally, I am also a small white. Recently, I am trying to write a lightweight web framework based on the contents of Park Ling’s book and the ideas of express source code plus the framework development in Liao Xuefeng python tutorial. At present, I have completed the functions of routing, middleware, ORM (encapsulation of orm2), template engine, etc. There are a lot of Chinese annotations in it, but it is still a bit messy. The code is definitely very easy to read. If you don’t mind, please ask for a star, which is being updated continuously …
Git address:https://github.com/wp3xpp/awesomeFreeMind-nodejs
Add a very good node learning website and make it easy to understand.http://nodeschool.io/zh-cn/index.html