Home >Web Front-end >HTML Tutorial >Common modules and usage

Common modules and usage

jacklove
jackloveOriginal
2018-06-11 23:42:141209browse

Common modules and usage

supervisor

  1. When nodejs implements http, no matter which part of the code is modified, nodejs must be terminated and re-run. will take effect. Because nodejs only goes back to parse the script file when a certain part is referenced for the first time, it will be accessed directly in the memory in the future to avoid repeated loading.

  2. supervisor will monitor your code changes and automatically restart nodejs

  3. Installation and configuration

        # npm install -g supervisor
        # supervisor app.js   运行服务器 ,当代码改动的时候会自动加载

Connect

Introduction

  1. Node is a middleware framework that performs middleware management based on the web server, similar to java filters. In connect, several commonly used components are provided, which can be used for request logs, static file services, request body parsing, session management, etc.

  2. Use, use the use method to register middleware into a queue of connect objects

        app.use(connect.staticCache());
        app.use(connect.static(__dirname + '/public'));
        app.use(connect.cookieParser());
        app.use(connect.session());
        app.use(connect.query());
        app.use(connect.bodyParser());
        app.use(connect.csrf());
        app.use(function (req, res, next) {
      // 中间件
        });
        app.listen(3001);
        复制代码
  3. Flow chart, there must be a middleware The software calls the res.end() method to inform the client that the request has been processed, otherwise the client will always be in a waiting state.

    #This article explains common modules and their usage. For more related content, please pay attention to the PHP Chinese website.

    Related recommendations:

    Simple PHP MySQL paging class

    Two tree array constructors without recursion

    Convert HTML to Excel, and realize printing and downloading functions

The above is the detailed content of Common modules and usage. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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