@santaz/nestjs-aws-sqs

## Installation


License
MIT
Install
npm install @santaz/nestjs-aws-sqs@1.0.2

Documentation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications, heavily inspired by Angular.

NPM Version Package License NPM Downloads Travis Linux Coverage Gitter Backers on Open Collective Sponsors on Open Collective

Description

An AWS SQS module for Nest.

Installation

/!\ Not yet published /!\

$ npm i --save nestjs-aws-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);
  }
}

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.