Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aws-message-bus-package

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-message-bus-package

[![NPM version](https://img.shields.io/npm/v/aws-message-bus-package.svg)](https://www.npmjs.com/package/aws-message-bus-package)

  • 1.0.15
  • unpublished
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Message Bus SDK for AWS Resources

NPM version

Table of Contents

Getting Started

1. Install

npm install aws-message-bus-package

2. Config File

You need to create a config.json file in your root/src project and input some AWS informations, like bellow:

{
    "endpoint": "http://localhost:4566",
    "region": "eu-west-2",
    "snsArnPrefix": "arn:aws:sns:eu-west-2:000000000000",
    "sqsArnPrefix": "arn:aws:sqs:eu-west-2:000000000000",
    "queuUrlPrefix": "http://sqs.eu-west-2.localhost.localstack.cloud:4566/000000000000"
}

3. Sample Usage

const { Infrastructure } = require('aws-message-bus-package');

async () => await Infrastructure.createQueue('your-queue-name');
async () => await Infrastructure.createTopic('your-topic-name');
async () => await Infrastructure.bindTopic('your-topic-name', 'your-queue-name');

API

Infrastructure.createQueue('queue-name')

Create a new SQS queue

Infrastructure.bindTopic('topic-name', 'queue-name')

  • Create a new SNS topic, if not exists
  • Subscribe a SNS topic in a SQS queue

Service.publishMessage('topic-name', {CONTENT})

Send a message to SNS topic to do broadcast

  • Content: any kind of type/object, this will be transformed into a JSON format

Service.sendMessage('queue-name', {CONTENT}, {PARAMS})

Send a message to SQS queue direct

  • Content: any kind of type/object, this will be transformed into a JSON format
  • Params: SQS.Types.SendMessageRequest
    • You don't need to inform:
      • MessageBody
      • MessageAttributes
      • QueueUrl

Service.scheduleMessage('topic-name', {CONTENT}, [SCHEDULED_DATE])

Send a message to EventBridge informing the SNS topic with the destination. This message will be consumed when it arrives on the scheduled date.

  • Content: any kind of type/object, this will be transformed into a JSON format

Service.handleConsumerMessage('queue-name', {RESILIENCE_PARAMS})

Handle a consumer to consume queue messages

  • Resilience Params:
    • maxRetryCount: max number of attempts until send to DLQ
    • delaySeconds: the time that will wait between attempts

Keywords

FAQs

Package last updated on 15 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc