npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mho96/nestjs-aws-sqs-transporter

v0.1.0

Published

nestjs microservice transport layer for Amazon Web Services Simple Queue System

Downloads

1

Readme

nestjs-aws-sqs-transporter

Custom transporter for nestjs microservices built on top of AWS Simple Queue Service

Description

This package is a lightweight implementation of Custom Transport Strategy and ClientProxy for AWS SQS. It has been made to fulfill needs of an internal project and thus is not yet made to cover all aspect of Transport strategies as NestJS provide. (i.e MessagePattern is not supported). This package is under development as the project relying on is growing.

Usage

The package provide support for consuming multiple SQS queues (normal & FIFO) just by providing the queue name inside @EventPattern

@EventPattern('<queue-name>.fifo') // Here the framework will look for messages inside the <queue-name>.fifo queue

To Access your Message.Body use the @Payload decorator like this

async myHandler(@Payload() payload: MyPayloadType) {

You can also access the SQSContext containing the rest of AWS ReceiveMessage Information doing the following

async myHandler(@Payload() payload: MyPayloadType, @Ctx() ctx: SQSContext) {
  ctx.getQueueName() // will give you the value of the queue you are listening to
  ctx.getAwsDetails() // will give you fileds part of the ReceiveMessage listened by the server

To configure the transport layer you need to do the following

app.connectMicroservice<MicroserviceOptions>({
    strategy: new ServerSQS({
      sqsUri: 'AWS_SQS_QUEUE_URI', // https://sqs.eu-west-3.amazonaws.com/<account-id>
      region: 'AWS_SQS_REGION', // eu-west-3
      apiVersion: 'AWS_SQS_API_VERSION', // 2012-11-05
    })
})

There are other options described into the SQSOptions interface.

To configure the ClientProxy to emit to a SQS queue, you can do the following in the constructor of your controller/service

    this.sqsClient = new ClientSQS({
      sqsUri: 'AWS_SQS_QUEUE_URI',
      region: 'AWS_SQS_REGION',
      apiVersion: 'AWS_SQS_API_VERSION',
      perSendMessageUniqIdOptions: { // this option allows you to ask for uniq id compute for aws sqs parameters that you want
        MessageDeduplicationId: true, // if you want a uniq id for MessageDeduplicationId set this to true
        MessageGroupId: true, // if you want a uniq id for MessageGroupId set this to true
      },
      serializer: new OutboundMessageIdentitySerializer(), // The serializer provided by the package for the ClientProxy is mandatory
    })

After configuring your sqsClient, you can emit to a SQS Queue doing the following

    this.sqsClient.emit(queueName, payload) // simple way passing your payload. It will be available in Message.Body of the AWS SendMessage Message

    // If you want to add custom AWS parameters you can pass them on your payload and the serializer ill look for them to create corresponding aws parameters for the SendMessage
    // see the serializer for supported parameters
    this.sqsClient.emit(queueName, { ...payload, MessageAttributes: { '<your attribute>': { "DataType": "String", "StringValue": "<string value>" } } })

Support

Feel free to open issues for improvement either bugfixing or new feature (such as @MessagePattern support)

Roadmap

There is no clear roadmap since it has been develop for a project purpose that do not benefit for more utilities than what the package offers as of today. But feel free to open issues for any needs Unit tests will be available soon.

Contributing

If you want to contribute to the package to help me solving issues, please email me at [email protected]

Authors and acknowledgment

This package has been made by mho96 [email protected]

License

This package is under a MIT License

Project status

Under Development