1.0.0 • Published 6 years ago

bragg-sqs v1.0.0

Weekly downloads
127
License
MIT
Repository
github
Last release
6 years ago

bragg-sqs Build Status

SQS middleware for bragg

Handle SQS events as bragg requests.

About

SQS is an event source for AWS Lambda, see the link for more information about configuration. Keep in mind that in case of errors, the request is retried untill it succeeds or the message retention period is expired.

Source: Retries on error with event sources with AWS Lambda

If you configure an Amazon SQS queue as an event source, AWS Lambda will poll a batch of records in the queue and invoke your Lambda function. If it fails, AWS Lambda will continue to process other messages in the batch. Meanwhile, AWS Lambda will continue to retry processing the failed message.

Install

$ npm install bragg-sqs

Usage

const app = require('bragg')();
const router = require('bragg-router')();
const sqs = require('bragg-sqs');

// Listen for events in the `TopicName` topic
router.post('sqs:QueueName', ctx => {
    ctx.body = ctx.request.body;
});

app.use(sqs());
app.use(router.routes());

exports.handler = app.listen();

The sqs: prefix is added by the middleware to the queuename from where the events are generated. The message of the event is provided in the body property of the request object.

API

braggSqs()

Install the bragg SQS middleware.

License

MIT © Simon