Interface Extension<Req, Res>

An interface that must be satisfied to register extensions

interface Extension<Req extends {}, Res extends {}> {
    name(): string;
    onRequest(isInitial: boolean): undefined | Req;
    onResponse(data: Res): Promise<void>;
    when(): ExtensionState;
}

Type Parameters

  • Req extends {}
  • Res extends {}

Methods

  • The extension name to go under 'extensions' in the request body.

    Returns string

    The JSON key.

  • A function which is called when the request JSON is being formed. Returns the data to insert under this key.

    Parameters

    • isInitial: boolean

      True when this is part of the initial request (send sticky params)

    Returns undefined | Req

    The request JSON to send.

  • A function which is called when there is response JSON under this extension.

    Parameters

    • data: Res

      The response JSON under the extension name.

    Returns Promise<void>