# sqs-to-lambda-async

> SQS To Lambda (Async)

Latest version **0.2.0** (published 2017-10-18) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install sqs-to-lambda-async
pnpm add sqs-to-lambda-async
yarn add sqs-to-lambda-async
bun add sqs-to-lambda-async
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2017-10-18 |
| First published | 2017-06-29 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.2.6 |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 26 |
| Author | IOpipe |
| Maintainers | teamiopipe |
| Keywords | lambda, serverless, sqs, iopipe |

## Links

- npm: https://www.npmjs.com/package/sqs-to-lambda-async
- Repository: https://github.com/iopipe/sqs-to-lambda-async
- Homepage: https://github.com/iopipe/sqs-to-lambda-async#readme
- Issues: https://github.com/iopipe/sqs-to-lambda-async/issues
- npm.io page: https://npm.io/package/sqs-to-lambda-async

## Dependencies (6)

- [debug](https://npm.io/package/debug.md) ^2.6.8
- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.7.20
- [p-settle](https://npm.io/package/p-settle.md) ^2.0.0
- [p-forever](https://npm.io/package/p-forever.md) ^1.0.1
- [babel-runtime](https://npm.io/package/babel-runtime.md) ^6.23.0

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2017-10-18
- 0.1.0 — 2017-06-29

## README

# SQS to Lambda (Async)

[![CircleCI](https://circleci.com/gh/iopipe/sqs-to-lambda-async.svg?style=svg&circle-token=54579c6f78d8dd9bcc6f96696a8481e7bc007596)](https://circleci.com/gh/iopipe/sqs-to-lambda-async)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

So you want to trigger a Lambda function via SQS? Great! You might be able to use [sqs-to-lambda](https://github.com/robinjmurphy/sqs-to-lambda). But what if you want your Lambda function to delete the SQS message, instead of the sqs-to-lambda implementation? Or, what if you want to setup multiple SQS => Lambda configurations? That's where this package comes in.

## Requirements
- Node >= `4.3.2`
- NPM >= `2.14.12`

## Install

With [yarn](https://yarnpkg.com) (recommended) in project directory:
```
yarn add sqs-to-lambda-async
```

With npm in project directory:
```
npm install sqs-to-lambda-async
```

Then, run your application:
```js
import worker from 'sqs-to-lambda-async';

worker([
  {
    queueUrl: 'sqs-queue-url-here',
    functionName: 'lambda-arn-here'
  }
]);
```

## Config

The package accepts an array of mapping configurations. A mapping configuration is an object with the following properties:

#### `queueUrl` (string: required)

The SQS queue you want to pull from.

#### `functionName` (string: required)

The Lambda function you want to execute.

#### `messageFormatter` (function: optional)

A function that allows transformation of the SQS message before send to Lambda.

Example:
```js
worker([
  {
    queueUrl: 'sqs-queue-url-here',
    functionName: 'lambda-arn-here',
    messageFormatter: (msg) => {
      return Object.assign({}, msg, {
        Body: 'reconfigure the sqs body here'
      })
    }
  }
]);
```

#### `deleteMessage` (boolean: optional, default = false)

Use this flag to allow this package to delete the message for you, instead of your Lambda function.

#### `maxNumberOfMessages` (integer: optional, default = 5)

The maximum number of messages to return. [AWS Documenation](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ReceiveMessage.html)

#### `waitTimeSeconds` (integer: optional, default = 5)

The duration (in seconds) for which the call waits for a message to arrive in the queue before returning. [AWS Documenation](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ReceiveMessage.html)

#### `postInvoke` (function: optional)

Optional callback that is invoked after each lambda invocation. Useful for error handling.

Example:
```js
worker([
  {
    queueUrl: 'sqs-queue-url-here',
    functionName: 'lambda-arn-here',
    postInvoke(err, value){
      // err will be undefined if lambda invoked successfully
      // value includes FunctionName and Payload
    }
  }
]);
```

## Contributing
- This project uses [Prettier](https://github.com/prettier/prettier). Please execute `npm run eslintFix` to auto-format the code before submitting pull requests.

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