@node-ts/bus-sqs-lambda
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-beta.1 • Public • Published

@node-ts/bus-sqs-lambda

An Amazon SQS and Lambda receiver for @node-ts/bus.

This package allows the host application to receive SQS messages via a Lambda handler directly, rather than subscribing to the SQS transport.

🔥 View our docs at https://bus.node-ts.com 🔥

🤔 Have a question? Join the Discussion 🤔

Installation

Install packages and their dependencies

npm i @node-ts/bus-sqs-lambda @node-ts/bus-sqs @node-ts/bus-core

Once installed, configure Bus to use this receiver during initialization:

import { Bus } from '@node-ts/bus-core'
import { SqsTransport, SqsTransportConfiguration } from '@node-ts/bus-sqs'
import { BusSqsLambdaReceiver } from '@node-ts/bus-sqs-lambda'

const sqsConfiguration: SqsTransportConfiguration = {
  awsRegion: process.env.AWS_REGION,
  awsAccountId: process.env.AWS_ACCOUNT_ID,
  queueName: `my-service`,
  deadLetterQueueName: `my-service-dead-letter`
}
const sqsTransport = new SqsTransport(sqsConfiguration)

// Configure Bus to run in a Lambda
const bus = Bus.configure()
  .withTransport(sqsTransport)
  .withReceiver(new BusSqsLambdaReceiver())
  .build()

await bus.initialize()

Usage

Once configured and initialized, any Lambda that is triggered by SQS messages can send these messages to Bus for processing and dispatch using the bus.receive method:

// Your lambda code

module.exports.handler = bus.receive

Package Sidebar

Install

npm i @node-ts/bus-sqs-lambda

Weekly Downloads

332

Version

1.0.0-beta.1

License

MIT

Unpacked Size

11.4 kB

Total Files

11

Last publish

Collaborators

  • adenhertog