Skip to content
This repository was archived by the owner on Jun 9, 2022. It is now read-only.

Coin-Market-Man/sqs

 
 

Repository files navigation

Nest Logo

Description

An AWS SQS module for Nest.

Installation

$ npm i --save @coin-market-man/sqs

Quick start

To consume data for a specific queue, you need to register it using the SQSModule, and provide a consumer class.

The consumer class is basically a class implementing the SQSMessageHandler interface, and decorated with @SQSConsumer. The @SQSConsumer annotation simply takes the name of the queue to consume.

For example:

// imports...

@SQSConsumer('test')
export class TestConsumer implements SQSMessageHandler {
  handleMessage(message: SQS.Message): void {
    console.log(`I received a message : ${message.Body}`);
  }
}

@Module({
  imports: [
    SQSModule.register([
      { name: 'test' }
    ])
  ],
  providers: [TestConsumer]
})
export class AppModule {}

The consumer can provide an async handleMessage method aswell:

@SQSConsumer('test')
export class TestConsumer implements SQSMessageHandler {
  constructor (private readonly myAwesomeService: MyAwesomeService) {}

  async handleMessage(message: SQS.Message): Promise<void> {
    await this.myAwesomeService.processMessage(body);
  }
}

License

Nest is MIT licensed.

About

An AWS SQS module for NestJS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 91.9%
  • JavaScript 8.1%