Server configuration

  • In most cases you only need to configure port, you can also customize the server parameters in ndsk.config.js
module.exports = (isPro)=>{
    return {
        server:{
            port:3000, 
            // ...
        }
    }
  • isPro equals true, indicating that the current environment is production, otherwise it is development environment, you can configure different parameters according to the environment

Allow the following parameters to be configured

port

  • Default value: 3000, the TCP port that the server will listen on.

address

Default value: :: if IPv6 is available, otherwise 0.0.0.0 (i.e. all available network interfaces).

compression

  • Default value: { minBytes: 1024 }
  • Defines the server’s handling of content-encoded requests. If false, response content encoding is disabled and the server does not perform any compression,

host

  • Default value: operating system host name, if not available, localhost

load

  • Default value
{ 
    sampleInterval: 1000,         //The sampling frequency in milliseconds. When set to 0, other load options are ignored. Defaults to 1000
    maxHeapUsedBytes: 0,          //Maximum V8 heap size, beyond which incoming requests will be rejected with an HTTP server timeout (503) response. Defaults to 0 (unlimited)
    maxRssBytes: 0,               //Maximum process RSS size, incoming requests exceeding this size will be rejected with an HTTP server timeout (503) response. Defaults to 0 (unlimited)
    maxEventLoopDelay: 0,         //The maximum event loop delay (in milliseconds) after which incoming requests will be rejected with an HTTP server timeout (503) response. Defaults to 0 (unlimited)
    maxEventLoopUtilization: 0    //The maximum event loop utilization value above which incoming requests will be rejected with an HTTP server timeout (503) response. Defaults to 0 (unlimited)
}

plugins

  • Default value: {} Plugin-specific configuration, accessible via server.settings.plugins. plugins is an object where each key is a plugin name and the value is a configuration

router

  • Controls how incoming request URIs are matched against the routing table. Default value:
{ 
    isCaseSensitive: true,       //Determines whether the paths "/example" and "/EXAMPLE" are considered different resources. Defaults to true
    stripTrailingSlash: true     //Remove the trailing slash from the passed path. Defaults to true
}

routes

  • Routes global configuration object, default value: None, configuration object can be viewed here

Note

  • The framework backend is completely developed based on hapi, and detailed server configuration can be viewed here

Next step

Route configuration