Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Request
    • SessionRequest

Index

Properties

app: RequestApplicationState

Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. See docs

auth: RequestAuth

Authentication information:

  • artifacts - an artifact object received from the authentication strategy and used in authentication-related actions.
  • credentials - the credential object received during the authentication process. The presence of an object does not mean successful authentication.
  • error - the authentication error is failed and mode set to 'try'.
  • isAuthenticated - true if the request has been successfully authenticated, otherwise false.
  • isAuthorized - true is the request has been successfully authorized against the route authentication access configuration. If the route has not access rules defined or if the request failed authorization, set to false.
  • mode - the route authentication mode.
  • strategy - the name of the strategy used. See docs
events: RequestEvents

Access: read only and the public podium interface. The request.events supports the following events:

  • 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding).
  • 'finish' - emitted when the request payload finished reading. The event method signature is function ().
  • 'disconnect' - emitted when a request errors or aborts unexpectedly. See docs
headers: Dictionary<string>

The raw request headers (references request.raw.req.headers). See docs

info: RequestInfo

Request information:

  • acceptEncoding - the request preferred encoding.
  • cors - if CORS is enabled for the route, contains the following:
  • isOriginMatch - true if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing decisions are made at that point in the request lifecycle.
  • host - content of the HTTP 'Host' header (e.g. 'example.com:8080').
  • hostname - the hostname part of the 'Host' header (e.g. 'example.com').
  • id - a unique request identifier (using the format '{now}:{connection.info.id}:{5 digits counter}').
  • received - request reception timestamp.
  • referrer - content of the HTTP 'Referrer' (or 'Referer') header.
  • remoteAddress - remote client IP address.
  • remotePort - remote client port.
  • responded - request response timestamp (0 is not responded yet). Note that the request.info object is not meant to be modified. See docs
logs: RequestLog[]

An array containing the logged request events. Note that this array will be empty if route log.collect is set to false.

method: HTTP_METHODS_PARTIAL_LOWERCASE

The request method in lower case (e.g. 'get', 'post').

mime: string

The parsed content-type header. Only available when payload parsing enabled and no payload error occurred.

orig: RequestOrig

An object containing the values of params, query, and payload before any validation modifications made. Only set when input validation is performed.

params: Dictionary<any>

An object where each key is a path parameter name with matching value as described in Path parameters.

paramsArray: string[]

An array containing all the path params values in the order they appeared in the path.

path: string

The request URI's pathname component.

payload: string | object | Buffer | Readable

The request payload based on the route payload.output and payload.parse settings. TODO check this typing and add references / links.

plugins: PluginsStates

Plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state.

pre: Dictionary<any>

An object where each key is the name assigned by a route pre-handler methods function. The values are the raw values provided to the continuation function as argument. For the wrapped response object, use responses.

preResponses: Dictionary<any>

Same as pre but represented as the response object created by the pre method.

query: RequestQuery

By default the object outputted from node's URL parse() method.

raw: { req: IncomingMessage; res: ServerResponse<IncomingMessage> }

An object containing the Node HTTP server objects. Direct interaction with these raw objects is not recommended.

  • req - the node request object.
  • res - the node response object.

Type declaration

  • req: IncomingMessage
  • res: ServerResponse<IncomingMessage>
response: ResponseObject | Boom<any>

Access: read / write (see limitations below). The response object when set. The object can be modified but must not be assigned another object. To replace the response with another from within an extension point, use reply(response) to override with a different response. In case of an aborted request the status code will be set to disconnectStatusCode.

route: RequestRoute

The request route information object and method See docs See docs

server: Server

Access: read only and the public server interface. The server object.

state: Dictionary<any>

An object containing parsed HTTP state information (cookies) where each key is the cookie name and value is the matching cookie content after processing using any registered cookie definition.

url: URL

The parsed request URI.

Methods

  • active(): boolean
  • Returns true when the request is active and processing should continue and false when the request terminated early or completed its lifecycle. Useful when request processing is a resource-intensive operation and should be terminated early if the request is no longer active (e.g. client disconnected or aborted early).

    Returns boolean

  • addListener<TArgs, Tcontext>(criteria: string | CriteriaObject, listener: Listener<Tcontext, TArgs>, context?: Tcontext): SessionRequest
  • addListener<TArgs, Tcontext>(criteria: string | CriteriaObject, listener: Listener<Tcontext, TArgs>, context?: Tcontext): SessionRequest
  • Subscribe a handler to an event. Same as podium.on().

    Type Parameters

    • TArgs extends any[] = unknown[]

    • Tcontext extends object = SessionRequest

    Parameters

    • criteria: string | CriteriaObject

      The subscription criteria.

    • listener: Listener<Tcontext, TArgs>

      The handler method set to receive event updates. The function signature depends on the block, spread, and tags options.

    • Optional context: Tcontext

      Optional object that binds to the listener handler.

    Returns SessionRequest

    A reference to the current emitter.

  • Type Parameters

    Parameters

    • criteria: string | CriteriaObject
    • listener: Listener<Tcontext, TArgs>
    • Optional context: Tcontext

    Returns SessionRequest

  • emit(criteria: string | EmitCriteria, data?: any): Promise<void>
  • Emits an event update to all the subscribed listeners.

    Parameters

    • criteria: string | EmitCriteria

      The event update criteria.

    • Optional data: any

      The value emitted to the subscribers.

    Returns Promise<void>

    Promise that resolves when all events has been processed. Any errors will cause an immediate rejection.

  • generateResponse(source: null | string | object, options?: { variety?: string; close?: any; marshal?: any; prepare?: any }): ResponseObject
  • Returns a response which you can pass into the reply interface where:

    Parameters

    • source: null | string | object

      the value to set as the source of the reply interface, optional.

    • Optional options: { variety?: string; close?: any; marshal?: any; prepare?: any }

      options for the method, optional.

      • Optional variety?: string
      • close?:function
        • close(response: ResponseObject): void
        • Parameters

          • response: ResponseObject

          Returns void

      • marshal?:function
        • marshal(response: ResponseObject): Promise<ResponseValue>
        • Parameters

          • response: ResponseObject

          Returns Promise<ResponseValue>

      • prepare?:function
        • prepare(response: ResponseObject): Promise<ResponseObject>
        • Parameters

          • response: ResponseObject

          Returns Promise<ResponseObject>

    Returns ResponseObject

    ResponseObject See docs

  • hasListeners(name: string): boolean
  • Returns whether an event has any listeners subscribed.

    Parameters

    • name: string

      the event name string.

    Returns boolean

    true if the event name has any listeners, otherwise false.

  • log(tags: string | string[], data?: string | object | (() => string | object)): void
  • Logs request-specific events. When called, the server emits a 'request' event which can be used by other listeners or plugins. The arguments are:

    Parameters

    • tags: string | string[]

      a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events.

    • Optional data: string | object | (() => string | object)

      (optional) an message string or object with the application data being logged. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. Any logs generated by the server internally will be emitted only on the 'request-internal' channel and will include the event.internal flag set to true.

    Returns void

    void See docs

  • on<TArgs, Tcontext>(criteria: string | CriteriaObject, listener: Listener<Tcontext, TArgs>, context?: Tcontext): SessionRequest
  • on<TArgs, Tcontext>(criteria: string | CriteriaObject, listener: Listener<Tcontext, TArgs>, context?: Tcontext): SessionRequest
  • Subscribe a handler to an event.

    Type Parameters

    • TArgs extends any[] = unknown[]

    • Tcontext extends object = SessionRequest

    Parameters

    • criteria: string | CriteriaObject

      The subscription criteria.

    • listener: Listener<Tcontext, TArgs>

      The handler method set to receive event updates. The function signature depends on the block, spread, and tags options.

    • Optional context: Tcontext

      Optional object that binds to the listener handler.

    Returns SessionRequest

    A reference to the current emitter.

  • Type Parameters

    Parameters

    • criteria: string | CriteriaObject
    • listener: Listener<Tcontext, TArgs>
    • Optional context: Tcontext

    Returns SessionRequest

  • once<TArgs, Tcontext>(criteria: string | Omit<CriteriaObject, "count">, listener: Listener<Tcontext, TArgs>, context?: Tcontext): SessionRequest
  • once<TArgs, Tcontext>(criteria: string | Omit<CriteriaObject, "count">, listener: Listener<Tcontext, TArgs>, context?: Tcontext): SessionRequest
  • once<TArgs, Tcontext>(criteria: string | Omit<CriteriaObject, "count">): Promise<TArgs>
  • once<TArgs, Tcontext>(criteria: string | Omit<CriteriaObject, "count">): Promise<TArgs>
  • Same as podium.on() with the count option set to 1.

    Can also be called without an listener to wait for a single event.

    Type Parameters

    • TArgs extends any[] = unknown[]

    • Tcontext extends object = SessionRequest

    Parameters

    • criteria: string | Omit<CriteriaObject, "count">

      The subscription criteria.

    • listener: Listener<Tcontext, TArgs>

      The handler method set to receive event updates. The function signature depends on the block, spread, and tags options.

    • Optional context: Tcontext

      Optional object that binds to the listener handler.

    Returns SessionRequest

    A reference to the current emitter.

  • Type Parameters

    Parameters

    • criteria: string | Omit<CriteriaObject, "count">
    • listener: Listener<Tcontext, TArgs>
    • Optional context: Tcontext

    Returns SessionRequest

  • Wait for a single event. The count option is fixed to 1.

    Type Parameters

    • TArgs extends any[] = unknown[]

    • Tcontext extends void = void

    Parameters

    • criteria: string | Omit<CriteriaObject, "count">

      The subscription criteria.

    Returns Promise<TArgs>

    Promise with array of emitted parameters.

  • Type Parameters

    • TArgs extends any[] = any[]

    • Tcontext extends void = void

    Parameters

    • criteria: string | Omit<CriteriaObject, "count">

    Returns Promise<TArgs>

  • registerEvent(events: Event | Event[]): void
  • Register the specified events and their optional configuration. Events must be registered before they can be emitted or subscribed to. This is done to detect event name mispelling and invalid event activities.

    Parameters

    • events: Event | Event[]

      The event(s) to register.

    Returns void

  • registerPodium(podiums: Podium | Podium[]): void
  • Registers another emitter as an event source for the current emitter (any event update emitted by the source emitter is passed to any subscriber of the current emitter).

    Note that any events registered with a source emitter are automatically added to the current emitter. If the events are already registered, they are left as-is.

    Parameters

    • podiums: Podium | Podium[]

      A Podium object or an array of objects, each added as a source.

    Returns void

  • Removes all listeners subscribed to a given event name.

    Parameters

    • name: string

      The event name string.

    Returns SessionRequest

    A reference to the current emitter.

  • removeListener(name: string, listener: Listener<any, any[]>): SessionRequest
  • Removes all listeners subscribed to a given event name matching the provided listener method.

    Parameters

    • name: string

      The event name string.

    • listener: Listener<any, any[]>

      The function reference provided when subscribed.

    Returns SessionRequest

    A reference to the current emitter.

  • setMethod(method: HTTP_METHODS_PARTIAL): void
  • Changes the request method before the router begins processing the request where:

    Parameters

    • method: HTTP_METHODS_PARTIAL

      is the request HTTP method (e.g. 'GET').

    Returns void

    void Can only be called from an 'onRequest' extension method. See docs

  • setUrl(url: string | URL, stripTrailingSlash?: boolean): void
  • Changes the request URI before the router begins processing the request where: Can only be called from an 'onRequest' extension method.

    Parameters

    • url: string | URL

      the new request URI. If url is a string, it is parsed with node's URL parse() method with parseQueryString set to true. url can also be set to an object compatible with node's URL parse() method output.

    • Optional stripTrailingSlash: boolean

      if true, strip the trailing slash from the path. Defaults to false.

    Returns void

    void See docs

Generated using TypeDoc