@creator.co/wapi - v1.8.1
    Preparing search index...

    Class default<BodyType>

    Represents a response object with various methods for building and manipulating the response.

    Type Parameters

    • BodyType = null

      The type of the response body.

    Index

    Constructors

    • Constructs a new Response object with the given status code, body, and optional behavior.

      Type Parameters

      • BodyType = null

      Parameters

      • statusCode: number

        The HTTP status code of the response.

      • body: BodyType

        The body of the response.

      • OptionaloptBehaviour: {
            disableTransactionID?: boolean;
            rawBody?: boolean;
            shouldStream?: boolean;
            throwOnErrors?: boolean;
        }

        Optional behavior configuration for the response.

        • OptionaldisableTransactionID?: boolean
        • OptionalrawBody?: boolean

          Indicates whether the response body should be treated as raw data.

        • OptionalshouldStream?: boolean

          Indicates whether the response should be streamed.

        • OptionalthrowOnErrors?: boolean

          Indicates whether errors should be thrown for non-successful status codes.

      Returns default<BodyType>

    Properties

    disableTransactionID: boolean

    Indicates whether the transaction ID is disabled.

    rawBody: boolean

    Indicates whether the request body should be treated as raw data.

    shouldStream: boolean

    Determines whether streaming is enabled or not.

    • True if streaming is enabled, false otherwise.
    throwOnErrors: boolean

    A boolean flag indicating whether to throw an error when encountering errors. If set to true, any errors encountered will result in an exception being thrown. If set to false, errors will be logged but the program will continue execution.

    Methods

    • Appends a header to the existing headers object.

      Parameters

      • key: string

        The key of the header.

      • value: any

        The value of the header.

      Returns void

      None

    • Appends a key-value pair into the body object.

      Parameters

      • key: string

        The key to append.

      • value: any

        The value to append.

      Returns void

      None

    • Builds the response for the given context and transaction.

      Parameters

      • context: Context

        The context object.

      • transaction: default<any, any, any, any, any>

        The transaction object.

      • optDoNotCallContext: boolean

        Optional flag to indicate whether to call the context or not.

      Returns Promise<void>

      • A promise that resolves when the response is built.
    • Get the status code of the response.

      Returns number

      The status code.

    • Creates a BadRequestResponse object with the given parameters.

      Parameters

      • Optionalmsg: string

        The error message.

      • OptionalerrCode: string

        The error code.

      • OptionaloptBody: any

        Optional additional body data.

      Returns default<ResponseErrorType>

      • The BadRequestResponse object.
    • Creates a BadRequestResponse object with rollback option.

      Parameters

      • msg: string

        The error message.

      • OptionalerrCode: string

        The error code.

      • OptionaloptBody: any

        Optional body to include in the response.

      Returns default<ResponseErrorType>

      • The BadRequestResponse object.
    • Creates a redirect response with the specified URL.

      Parameters

      • url: string

        The URL to redirect to.

      Returns default<null>

      • The redirect response.
    • Creates a simple HTTP response with the given body and optional status code.

      Type Parameters

      • BodyType

      Parameters

      • body: BodyType

        The body of the response.

      • OptionaloptionalCode: number

        The optional status code of the response. Defaults to 200.

      Returns default<BodyType>

      • The created response object.
    • Creates a success response with no content.

      Returns default<null>

      A response object with a status code of 204 and no content.

    • Creates a success response object with a streaming body and specified content type.

      Parameters

      • stream: any

        The stream object to be used as the response body.

      • contentType: string

        The content type of the response.

      Returns default

      • The success response object.