Documentation
    Preparing search index...
    • Define configuration for the HTTP server

      Parameters

      • config: {
            trustProxy?:
                | string
                | boolean
                | ((address: string, distance: number) => boolean);
            subdomainOffset?: number;
            generateRequestId?: boolean;
            createRequestId?: {};
            allowMethodSpoofing?: boolean;
            getIp?: (request: any) => string;
            etag?: boolean;
            jsonpCallbackName?: string;
            cookie?: {
                domain?: string;
                expires?: Date | (() => Date);
                httpOnly?: boolean;
                maxAge?: string | number;
                path?: string;
                sameSite?: boolean | "lax" | "none" | "strict";
                secure?: boolean;
                partitioned?: boolean;
                priority?: "low" | "medium" | "high";
            };
            useAsyncLocalStorage?: boolean;
            qs?: {
                parse?: {
                    depth?: number;
                    parameterLimit?: number;
                    allowSparse?: boolean;
                    arrayLimit?: number;
                    comma?: boolean;
                };
                stringify?: {
                    encode?: boolean;
                    encodeValuesOnly?: boolean;
                    arrayFormat?: "indices"
                    | "brackets"
                    | "repeat"
                    | "comma";
                    skipNulls?: boolean;
                };
            };
            keepAliveTimeout?: number;
            headersTimeout?: number;
            requestTimeout?: number;
            timeout?: number;
        }
        • OptionaltrustProxy?: string | boolean | ((address: string, distance: number) => boolean)
        • OptionalsubdomainOffset?: number

          URL segments to ignore when extracting subdomains from a URL. Defaults to 2

        • OptionalgenerateRequestId?: boolean

          Enabling the flag will generated a unique request id from every HTTP request.

          The request id can be accessed using the "request.id()" method. Also, the value of x-request-id header is used as the id (if it exists).

          Defaults to false

        • OptionalcreateRequestId?: {}
        • OptionalallowMethodSpoofing?: boolean

          Method spoofing allows changing the request method using the query string. For example: Making a POST request on URL /users/1?_method=PATCH will be handled by the patch route.

          Defaults to false

        • OptionalgetIp?: (request: any) => string

          A custom implementation to get the request ip address

        • Optionaletag?: boolean

          Whether or not to generate etags for responses. Etags can be enabled/disabled when sending response as well.

          Defaults to false

        • OptionaljsonpCallbackName?: string

          The callback name for the JSONP response.

          Defaults to 'callback'

        • Optionalcookie?: {
              domain?: string;
              expires?: Date | (() => Date);
              httpOnly?: boolean;
              maxAge?: string | number;
              path?: string;
              sameSite?: boolean | "lax" | "none" | "strict";
              secure?: boolean;
              partitioned?: boolean;
              priority?: "low" | "medium" | "high";
          }

          Default options to apply when setting cookies

          • Optionaldomain?: string

            Domain name for the cookie

          • Optionalexpires?: Date | (() => Date)

            Expiration date for the cookie or function that returns the date

          • OptionalhttpOnly?: boolean

            Whether the cookie should be accessible only through HTTP(S)

          • OptionalmaxAge?: string | number

            Maximum age of the cookie in seconds or as a string

          • Optionalpath?: string

            URL path for which the cookie is valid

          • OptionalsameSite?: boolean | "lax" | "none" | "strict"

            SameSite attribute to control cross-site request behavior

          • Optionalsecure?: boolean

            Whether the cookie should only be sent over HTTPS

          • Optionalpartitioned?: boolean

            Whether the cookie should be partitioned (optional)

          • Optionalpriority?: "low" | "medium" | "high"

            Priority level for the cookie (optional)

        • OptionaluseAsyncLocalStorage?: boolean

          Whether or not to create an async local storage store for the HTTP context.

          Defaults to false

        • Optionalqs?: {
              parse?: {
                  depth?: number;
                  parameterLimit?: number;
                  allowSparse?: boolean;
                  arrayLimit?: number;
                  comma?: boolean;
              };
              stringify?: {
                  encode?: boolean;
                  encodeValuesOnly?: boolean;
                  arrayFormat?: "indices"
                  | "brackets"
                  | "repeat"
                  | "comma";
                  skipNulls?: boolean;
              };
          }

          Config for query string parser

          • Optionalparse?: {
                depth?: number;
                parameterLimit?: number;
                allowSparse?: boolean;
                arrayLimit?: number;
                comma?: boolean;
            }

            Configuration options for parsing query strings

            • Optionaldepth?: number

              Nesting depth till the parameters should be parsed.

              Defaults to 5

            • OptionalparameterLimit?: number

              Number of parameters to parse.

              Defaults to 1000

            • OptionalallowSparse?: boolean

              Allow sparse elements in an array.

              Defaults to false

            • OptionalarrayLimit?: number

              The max limimit for the array indices. After the given limit the array indices will be converted to an object, where the index is the key.

              Defaults to 20

            • Optionalcomma?: boolean

              Join comma seperated query string values to an array

              Defaults to false

          • Optionalstringify?: {
                encode?: boolean;
                encodeValuesOnly?: boolean;
                arrayFormat?: "indices" | "brackets" | "repeat" | "comma";
                skipNulls?: boolean;
            }

            Configuration options for stringifying query objects

            • Optionalencode?: boolean

              URI encode the stringified query string

              Defaults to true

            • OptionalencodeValuesOnly?: boolean

              URI encode but only the values and not the keys

              Defaults to false

            • OptionalarrayFormat?: "indices" | "brackets" | "repeat" | "comma"

              Define the format in which arrays should be serialized.

              • indices: a[0]=b&a[1]=c
              • brackets: a[]=b&a[]=c
              • repeat: a=b&a=c
              • comma: a=b,c

              Defaults to "indices"

            • OptionalskipNulls?: boolean

              Whether or not to skip null values when serializing. When set to false, the null values will be treated as an empty string.

              Defaults to: false

        • OptionalkeepAliveTimeout?: number

          The number of milliseconds of inactivity a server needs to wait for additional incoming data after it has finished writing the last response.

          5000 (as per Node.js defaults)
          
        • OptionalheadersTimeout?: number

          Limit the amount of time the parser will wait to receive the complete HTTP headers.

          60000 (as per Node.js defaults)
          
        • OptionalrequestTimeout?: number

          Sets the timeout value in milliseconds for receiving the entire request from the client

          300000 (as per Node.js defaults)
          
        • Optionaltimeout?: number

          The number of milliseconds of inactivity before a socket is presumed to have timed out

          0 (as per Node.js defaults)
          

      Returns ServerConfig