API Reference
    Preparing search index...
    • A middiy middleware to parse your event.

      Type Parameters

      • TSchema extends ZodType<any, ZodTypeDef, any>
      • TEnvelope extends Envelope
      • TSafeParse extends boolean = false

      Returns MiddlewareObj<ParserOutput<TSchema, TEnvelope, TSafeParse>>

      import { parser } from '@aws-lambda-powertools/parser/middleware';
      import middy from '@middy/core';
      import { sqsEnvelope } from '@aws-lambda-powertools/parser/envelopes/sqs;'

      const oderSchema = z.object({
      id: z.number(),
      description: z.string(),
      quantity: z.number(),
      });

      type Order = z.infer<typeof oderSchema>;

      export const handler = middy(
      async (event: Order, _context: unknown): Promise<void> => {
      // event is validated as sqs message envelope
      // the body is unwrapped and parsed into object ready to use
      // you can now use event as Order in your code
      }
      ).use(parser({ schema: oderSchema, envelope: sqsEnvelope }));