Class MoxyResponse

Hierarchy

Constructors

Properties

duration?: number

Request duration in ms

id: string

Unique request UUID

Accessors

  • get body(): string | Buffer<ArrayBufferLike> | Record<string, unknown>

    The response body

    Returns string | Buffer<ArrayBufferLike> | Record<string, unknown>

Methods

  • Overwrite writableend to store body internally

    Parameters

    • ...args: unknown[]

      The arguments

    Returns this

  • Gets the content type from file extention

    Parameters

    • filename: string

      The filename

    Returns string

  • Parse the response body based on content-type

    Parameters

    • body: Buffer

      The body

    Returns string | Buffer<ArrayBufferLike> | Record<string, unknown>

  • Sends a json response

    Parameters

    • json: string | unknown[] | Record<string, unknown>

      The json

    • Optionaloptions: SendOptions

      Reponse options

    Returns this

  • Set response headers The writeHead method buffers headers, so they are not available for logging without calling setHeaders

    Parameters

    • headers:
          | Headers
          | Map<string, string | number | readonly string[]>
          | Record<string, string | number | readonly string[]>

      The headers

    Returns this

  • Override writablewrite to store body internally

    Parameters

    • chunk: string

      The chunk

    • ...args: unknown[]

      The arguments

    Returns boolean