Type alias ServerOptions

ServerOptions: {
    bind?: string;
    compression?: {
        http?: {
            enabled?: boolean;
            maxSize?: number;
            minSize?: number;
            preferOrder?: CompressionAlgorithm[];
        };
        ws?: {
            enabled?: boolean;
            maxSize?: number;
        };
    };
    logging?: {
        debug?: boolean;
        error?: boolean;
        warn?: boolean;
    };
    methods?: {
        head?: boolean;
        trace?: boolean;
    };
    performance?: {
        eTag?: boolean;
        lastModified?: boolean;
    };
    port?: number;
    proxy?: {
        compress?: boolean;
        credentials?: {
            authenticate?: boolean;
            password?: string;
            username?: string;
        };
        enabled?: boolean;
        force?: boolean;
        header?: Lowercase<string>;
        ips?: {
            list?: (network.IPAddress | network.Subnet)[];
            mode?: "whitelist" | "blacklist";
            validate?: boolean;
        };
    };
    version?: boolean;
}

Type declaration

  • Optional bind?: string

    THe IP Address to bind the server to

    Default

    "0.0.0.0"
    

    Since

    0.0.4

  • Optional compression?: {
        http?: {
            enabled?: boolean;
            maxSize?: number;
            minSize?: number;
            preferOrder?: CompressionAlgorithm[];
        };
        ws?: {
            enabled?: boolean;
            maxSize?: number;
        };
    }

    Various Compression-Related Settings

    Since

    9.0.0

    • Optional http?: {
          enabled?: boolean;
          maxSize?: number;
          minSize?: number;
          preferOrder?: CompressionAlgorithm[];
      }

      HTTP Compression Settings

      Since

      9.0.0

      • Optional enabled?: boolean

        Whether HTTP Compression is enabled

        Default

        true
        

        Since

        9.0.0

      • Optional maxSize?: number

        The Maximum Size of an Item allowed to be compressed

        Default

        size(10).mb()
        

        Since

        9.0.0

      • Optional minSize?: number

        The Minimum Size of an Item allowed to be compressed

        Default

        size(1).kb()
        
      • Optional preferOrder?: CompressionAlgorithm[]

        The Order in which to prefer Compression Algorithms, non included wont be used

        Default

        ["brotli", "gzip", "deflate"]
        

        Since

        9.0.0

    • Optional ws?: {
          enabled?: boolean;
          maxSize?: number;
      }

      WebSocket Compression Settings

      Since

      9.0.0

      • Optional enabled?: boolean

        Whether WebSocket Compression is enabled

        Default

        true
        

        Since

        9.0.0

      • Optional maxSize?: number

        The Maximum Size of an Item allowed to be compressed

        Default

        size(1).mb()
        

        Since

        9.0.0

  • Optional logging?: {
        debug?: boolean;
        error?: boolean;
        warn?: boolean;
    }

    Various Logging-Related Settings

    Since

    7.4.0

    • Optional debug?: boolean

      Whether to enable DEBUG Logs

      Default

      false
      

      Since

      7.4.0

    • Optional error?: boolean

      Whether to enable ERROR Logs

      Default

      true
      

      Since

      7.4.0

    • Optional warn?: boolean

      Whether to enable WARN Logs

      Default

      true
      

      Since

      7.4.0

  • Optional methods?: {
        head?: boolean;
        trace?: boolean;
    }

    The HTTP Methods that should automatically be handled for you

    Since

    9.5.0

    • Optional head?: boolean

      Whether to automatically handle HEAD Requests

      Default

      true
      

      Since

      9.5.0

    • Optional trace?: boolean

      Whether to automatically handle TRACE Requests

      Default

      false
      

      Since

      9.5.0

  • Optional performance?: {
        eTag?: boolean;
        lastModified?: boolean;
    }

    Various Performance-Related Settings

    Since

    6.3.0

    • Optional eTag?: boolean

      Whether to include ETag Headers on every request with a direct Body

      Default

      true
      

      Since

      6.3.0

    • Optional lastModified?: boolean

      Whether to include Last-Modified Headers on every request that serves a file

      Default

      true
      

      Since

      6.3.0

  • Optional port?: number

    The Port to use for the Server, can be random using 0

    Default

    0
    

    Since

    0.0.1

  • Optional proxy?: {
        compress?: boolean;
        credentials?: {
            authenticate?: boolean;
            password?: string;
            username?: string;
        };
        enabled?: boolean;
        force?: boolean;
        header?: Lowercase<string>;
        ips?: {
            list?: (network.IPAddress | network.Subnet)[];
            mode?: "whitelist" | "blacklist";
            validate?: boolean;
        };
    }

    HTTP Proxy Options

    Since

    8.0.0

    • Optional compress?: boolean

      Whether to compress the requests

      Default

      false
      

      Since

      9.0.0

    • Optional credentials?: {
          authenticate?: boolean;
          password?: string;
          username?: string;
      }

      The Credentials that the proxy will use

      Since

      8.0.0

      • Optional authenticate?: boolean

        Whether to authenticate proxy requests

        Default

        false
        

        Since

        8.0.0

      • Optional password?: string

        The Password required to authenticate

        Default

        "proxy"
        

        Since

        8.0.0

      • Optional username?: string

        The Username required to authenticate

        Default

        "proxy"
        

        Since

        8.0.0

    • Optional enabled?: boolean

      Whether to check for proxies and use alternate IPs

      Default

      false
      

      Since

      8.0.0

    • Optional force?: boolean

      Whether to force all requests through the proxy

      Default

      false
      

      Since

      8.0.0

    • Optional header?: Lowercase<string>

      The Header to use for getting the actual IP address, it must only include the IP address

      Default

      "x-forwarded-for"
      

      Since

      8.0.0

    • Optional ips?: {
          list?: (network.IPAddress | network.Subnet)[];
          mode?: "whitelist" | "blacklist";
          validate?: boolean;
      }

      The IPs the server will validate against

      Since

      9.0.0

      • Optional list?: (network.IPAddress | network.Subnet)[]

        The List of Authorized (or Unauthorized) Proxy IPs

        Default

        [...ReverseProxyIps.LOCAL, ...ReverseProxyIps.CLOUDFLARE]
        

        Since

        9.0.0

      • Optional mode?: "whitelist" | "blacklist"

        The Mode in which to validate the list

        Default

        "whitelist"
        

        Since

        9.0.0

      • Optional validate?: boolean

        Whether to validate proxy ips

        Default

        false
        

        Since

        9.0.0

  • Optional version?: boolean

    Whether to add the rjweb-server header that contains the version

    Default

    true
    

    Since

    9.0.0