UNPKG

@swarmion/serverless-contracts

Version:

Generate and use type-safe contracts between your Serverless services.

21 lines 1.52 kB
import { SQSContract } from '../sqsContract'; import { GetSQSHandlerOptions, SQSHandler, SqsMessageAttributesType, SqsMessageBodyType, SwarmionLambdaSQSHandler, SwarmionSQSHandler } from '../types'; /** * Returns the Swarmion handler for SQS. * The wrapper parses the body and attributes of the SQS messages * By default, * It calls the handle with only one record of the batch. * The record is parsed and typed. * It can throw an error if the record is invalid. * The wrapper will catch it and inform the SQS that the record couldn't be processed * following the batch failure reporting spec. * https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting * * If handleBatchedRecords option is set to false, * It calls the handler with all the records parsed and typed. * The handler must process all the records and handle errors if necessary. * * The handler function can define additional arguments */ export declare const getSQSHandler: <Contract extends SQSContract, MessageBody = SqsMessageBodyType<Contract>, MessageAttributes = SqsMessageAttributesType<Contract>, HandleRecords extends boolean = true>(contract: Contract, options: GetSQSHandlerOptions<HandleRecords>) => <AdditionalArgs extends unknown[] = []>(handler: HandleRecords extends false ? SwarmionLambdaSQSHandler<MessageBody, MessageAttributes, AdditionalArgs> : SwarmionSQSHandler<MessageBody, MessageAttributes, AdditionalArgs>) => SQSHandler<AdditionalArgs>; //# sourceMappingURL=lambdaHandler.d.ts.map