rest-vir - v2.2.0
    Preparing search index...

    Function finalizeOptions

    • Combines user defined options with default options to create a full options type for startApiServer.

      Parameters

      Returns {
          bodyLimit: number;
          connectionTimeout: number;
          host: string;
          keepAliveTimeout: number;
          lockPort: boolean;
          port: number;
          preventWorkerRespawn: boolean;
          requestTimeout: number;
          trustProxy?: string | number | boolean | string[] | null;
          webSocketMaxPayload: number;
          workerCount: number;
      }

      • bodyLimit: number

        Maximum size, in bytes, of incoming request bodies. Requests over this size are rejected with HTTP 413. Forwarded to Fastify's bodyLimit. Default matches Fastify's default.

        1048576 // 1 MiB
        
      • connectionTimeout: number

        Max time, in milliseconds, the server will wait between TCP connect and the first request byte. Slowloris and idle-connection attackers consume socket slots without this. Forwarded to Fastify's connectionTimeout.

        0 // no timeout. Set this in production
        
      • host: string

        The host name that the server should listen to. Defaults to 'localhost' (loopback only) so accidentally exposing a dev server is not the default. Set to '0.0.0.0' for containers (Docker, k8s) that need the server reachable on all interfaces.

        'localhost'
        
      • keepAliveTimeout: number

        Max time, in milliseconds, between keep-alive requests. Forwarded to Fastify's keepAliveTimeout.

        72000 // matches Fastify's default
        
      • lockPort: boolean

        Prevent automatically choosing an available port if the provided port is already in use. This will cause runApi to simply crash if the given port is in use.

        false
        
      • port: number

        The port that the service should listen to requests on. Note that if lockPort is not set, runApi will try to find the first available port starting with this given port property (so the actual server may be listening to a different port).

        If this property is set to false, no port will be listened to (so you can manually do that later if you wish).

        // the service definition's port or
        3000
      • preventWorkerRespawn: boolean

        If set to true, a multi-threaded service (workerCount > 1) will not automatically respawn its workers. This has no effect on single-threaded services (workerCount == 1).

        false
        
      • requestTimeout: number

        Max time, in milliseconds, between the start of a request and when the response is sent. 0 disables the timeout. Forwarded to Fastify's requestTimeout.

        0
        
      • OptionaltrustProxy?: string | number | boolean | string[] | null

        Trust proxy headers (X-Forwarded-For, X-Forwarded-Proto, etc.). Required when running behind a reverse proxy / load balancer / CDN so request.ip reflects the actual client. Forwarded to Fastify's trustProxy.

        • true: trust headers from any hop.
        • false: trust nothing (default).
        • A string or list of strings: trust the listed CIDR ranges or IPs.
        • A number: trust that many hops.
        false
        
      • webSocketMaxPayload: number

        Maximum size, in bytes, of an inbound WebSocket message frame. Larger payloads close the connection with 1009 (message too big). Passed through to @fastify/websocket's options.maxPayload.

        1048576 // 1 MiB
        
      • workerCount: number

        The number of workers to split the server into (for parallel request handling).

        cpus().length - 1
        

      runApiOptionsShape for option explanations.