Fake Mirrors
    Preparing search index...

    Class HttpServerWebSocketContext

    Represents the http-server context for a WebSocket connections.

    Handles WebSocket connection lifecycle with duplex streaming support.

    • Creates a new WebSocket context.

      Parameters

      • ws: WebSocket

        The WebSocket connection.

      • req: IncomingMessage

        The server request object.

      Returns HttpServerWebSocketContext

    finishTime: number = 0

    Timestamp when processing finished.

    Request method wrapper.

    requestBody: HttpBodyWrap

    Request body wrapper.

    requestHeaders: HttpHeadersWrap

    Request headers wrapper.

    responseBody: HttpBodyWrap

    Response body wrapper.

    responseHeaders: HttpHeadersWrap

    Response headers wrapper.

    startTime: number = ...

    Timestamp when processing started.

    state: object = {}

    Associated shared state.

    Response status wrapper.

    trace: string[] = []

    Names of middleware that have already been processed.

    The variant of context type.

    Request URL wrapper.

    • get clientIp(): string | null

      Parsed client IP address.

      Returns string | null

    • get isBot(): boolean

      Whether the client is identified as a bot.

      Returns boolean

    • get isComplete(): boolean

      Returns boolean

    • get requestStream(): Readable

      Returns Readable

    • get responseStream(): Writable

      Returns Writable

    • get totalTime(): number

      Total processing time.

      Returns number

    • get userAgent(): ParsedResult | null

      Parsed User-Agent data.

      Returns ParsedResult | null

    • Returns void

    • Dumps a serializable representation of a context for logging.

      Returns object

      A plain object with context details.

    • Gets value by key from state.

      Type Parameters

      • T
      • K extends string | number | symbol

      Parameters

      • key: K

      Returns NonNullable<T[K]>

    • Checks HTTP method and URL pathname.

      Parameters

      • method:
            | "HEAD"
            | "GET"
            | "POST"
            | "PUT"
            | "PATCH"
            | "DELETE"
            | "OPTIONS"
            | ("HEAD" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS")[]

        The single method string or an array of methods to check.

      • path: string | RegExp | (string | RegExp)[]

        The string path, RegExp pattern to match or array of both.

      Returns boolean

      true if the current method and pathname matches, false otherwise.

    • Parameters

      • bodySizeLimit: number

      Returns Promise<void>

    • Returns void

    • Returns Promise<void>

    • Sets value by key to state.

      Type Parameters

      • T
      • K extends string | number | symbol

      Parameters

      • key: K
      • value: T[K]

      Returns void