JSPM

  • Created
  • Published
  • Downloads 1393
  • Score
    100M100P100Q120023F
  • License MIT

An AWS SQS transport adapter for @node-ts/bus-core.

Package Exports

  • @node-ts/bus-sqs
  • @node-ts/bus-sqs/dist/sqs-transport

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@node-ts/bus-sqs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@node-ts/bus-sqs

An Amazon SQS transport adapter for @node-ts/bus

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

🤔 Have a question? Join our Discord 🤔

Installation

Install packages and their dependencies

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

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

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

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 use SQS as a transport
const run = async () => {
  await Bus
    .configure()
    .withTransport(sqsTransport)
    .initialize()
}
run.catch(console.error)

Development

Local development can be done with the aid of docker to run the required infrastructure. To do so, run:

docker run -e SERVICES=sqs,sns -e DEFAULT_REGION=us-east-1 -p 4566-4583:4566-4583 localstack/localstack

This will create a localstack instance running and exposing a mock sqs/sns that's compatible with the AWS-SDK. This same environment is used when running integration tests for the SqsTransport.