# sqs-loop

> AWS SQS consumer helper for the gentleman that uses promises

Latest version **1.0.1** (published 2016-07-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install sqs-loop
pnpm add sqs-loop
yarn add sqs-loop
bun add sqs-loop
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-07-25 |
| First published | 2016-07-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Henrique Grolli |
| Maintainers | guax |

## Links

- npm: https://www.npmjs.com/package/sqs-loop
- Repository: https://github.com/daime/sqs-loop
- Homepage: https://github.com/daime/sqs-loop#readme
- Issues: https://github.com/daime/sqs-loop/issues
- npm.io page: https://npm.io/package/sqs-loop

## Dependencies (2)

- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.4.9
- [bluebird](https://npm.io/package/bluebird.md) ^3.4.1

## Recent versions

- 1.0.1 (latest) — 2016-07-25
- 1.0.0 — 2016-07-07

## README

SQS-LOOP
========

SQS polling lib to ease the creation of consumers that run forever.

```bash
npm install --save sqs-loop
```

```js
const sqsLoop = require('sqs-loop');

sqsLoop.aws.config.update({
    accessKeyId: process.env.AWS_ACCESS_KEY_ID,
    secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
    region: 'us-east-1'
});

const params = {
    QueueName: 'awesome-queue', // auto create and resolves queue url
    VisibilityTimeout: 5,
    MaxNumberOfMessages: 5,
    WaitTimeSeconds: 20
};

// Callback will be called once per message in parallel by MaxNumberOfMessages
sqsLoop.loop(params, message => {
    const body = JSON.parse(message.Body);

    /*
     * work with our message
     */

    // If we want to loop no further
    // return sqsLoop.stop();

    // If we want to keep the messsage in SQS
    // return sqsLoop.keep();
});
```

## Return values

 * __sqsLoop.stop()__: stops the loop and resolves the promise
 * __sqsLoop.keep()__: avoid removal of the message from SQS queue
 * __promise rejections__: keep the message on the queue.
 * __promise resolves or normal returns__: removes the message from SQS queue

---
_Source: https://npm.io/package/sqs-loop · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
