API Gateway envelope to extract data within body key

Hierarchy

  • Envelope
    • ApiGatewayEnvelope

Constructors

Methods

Constructors

Methods

  • Internal

    Abstract function to parse the content of the envelope using provided schema. Both inputs are provided as unknown by the user. We expect the data to be either string that can be parsed to json or object.

    Type Parameters

    • T extends ZodType<any, ZodTypeDef, any>

    Parameters

    • data: unknown

      data to parse

    • schema: T

      schema

    Returns TypeOf<T>

  • Abstract function to safely parse the content of the envelope using provided schema. safeParse is used to avoid throwing errors, thus we catuch all errors and wrap them in the result.

    Type Parameters

    • T extends ZodType<any, ZodTypeDef, any>

    Parameters

    • data: unknown
    • schema: T

    Returns ParsedResult<unknown, TypeOf<T>>