Class RequestContext<MiddlewareData>

Type Parameters

  • MiddlewareData extends Record<any, any> = any

Constructors

Properties

aborted: boolean = false
body: {
    awaiting: boolean;
    callbacks: ((raw) => void)[];
    chunks: Buffer<ArrayBufferLike>[];
    parsed: ParsedBody;
    raw: null | Buffer<ArrayBufferLike>;
    type: "raw" | "json" | "url-encoded";
} = ...

Body / Ws Message Data

Type declaration

  • awaiting: boolean

    Whether the Body is being awaited

    Since

    9.0.0

  • callbacks: ((raw) => void)[]

    Callbacks that get called when full body is resolved

    Since

    9.0.0

  • chunks: Buffer<ArrayBufferLike>[]

    The Chunks of the Body

    Since

    9.0.0

  • parsed: ParsedBody

    The Parsed Data of the Body

    Since

    9.0.0

  • raw: null | Buffer<ArrayBufferLike>

    The Raw Data of the Body

    Since

    9.0.0

  • type: "raw" | "json" | "url-encoded"

    The Type of the parsed Body

    Since

    9.0.0

Since

9.0.0

chunked: boolean = false

Whether the Request is chunked

Since

9.0.0

cookies: null | ValueCollection<string, string, Cookie> = null

The Cookies of the Request

Since

9.0.0

endFn: boolean = false

Whether the EndFn was called

Since

9.0.0

error: null | RuntimeError = null

The Error this request encountered

Since

9.0.0

executeSelf: (() => boolean | Promise<boolean>) = ...

Type declaration

    • (): boolean | Promise<boolean>
    • Returns boolean | Promise<boolean>

file: null | string = null

The File to print at the end of the request

Warn

Only used in static routes, do not use in other routes

Since

9.0.0

fragments: null | ValueCollection<string, string, string> = null

The Fragments of the Request

Since

9.0.0

The Global Context

Since

9.0.0

headers: ValueCollection<string, string, string>

The Headers of the URL Path

Since

9.0.0

ip: {
    isInternal: boolean;
    isProxied: boolean;
    port: number;
    value: string;
}

IP Information

Type declaration

  • isInternal: boolean

    Whether the IP is from an internal request

    Since

    9.3.0

  • isProxied: boolean

    Whether the IP is Proxied

    Since

    9.0.0

  • port: number

    The Port that the IP is using

    Since

    9.0.0

  • value: string

    The Value of the IP

    Since

    9.0.0

Since

9.0.0

middlewareData: Record<string, any> = {}
middlewares: UsableMiddleware[]
params: ValueCollection<string, string, string> = ...

The Params of the URL Path

Since

9.0.0

queries: null | ValueCollection<string, string, string> = null

The Queries of the Request

Since

9.0.0

response: {
    content: Content;
    cookies: ValueCollection<string, Cookie, Cookie>;
    headers: ValueCollection<string, string, string>;
    prettify: boolean;
    status: number;
    statusText: null | string;
} = ...

The Response Data

Type declaration

  • content: Content

    The Content to send

    Default

    []
    

    Since

    9.0.0

  • cookies: ValueCollection<string, Cookie, Cookie>

    The Cookies to add

    Since

    9.0.0

  • headers: ValueCollection<string, string, string>

    The Headers to send

    Since

    9.0.0

  • prettify: boolean

    Whether to prettify the content

    Default

    false
    

    Since

    9.0.0

  • status: number

    The Status Code to send

    Default

    200
    

    Since

    9.0.0

  • statusText: null | string

    The Status Text to send

    Default

    null
    

    Since

    9.0.0

Since

9.0.0

route: null | default<"http"> | default<"ws"> | default<"static"> = null

The Route, if found

Since

9.0.0

server: Server<any, [], {}>

Type declaration

    started: number = ...
    type: "http" | "ws"

    The Type of the Request

    Since

    9.0.0

    url: default

    The URL Object

    Since

    9.0.0

    vary: Set<string> = ...

    What headers affected the response (vary)

    Since

    9.3.4

    yielded: null | default<unknown> = null

    The Yielded Response

    Since

    9.2.0

    Methods

    • Get the Route that matches the input

      Parameters

      • method: "CONNECT" | "TRACE" | "OPTIONS" | "DELETE" | "PATCH" | "HEAD" | "POST" | "PUT" | "GET"
      • path: string

      Returns null | default<"http"> | default<"ws">

      Since

      9.4.0

    • Set Code to execute at the end end of the request, return a boolean describing if you want the normal request end to proceed too

      Parameters

      • callback: (() => boolean | Promise<boolean>)
          • (): boolean | Promise<boolean>
          • Returns boolean | Promise<boolean>

      Returns this

      Since

      9.0.0