# @repit/lambda-send

> AWS Lambda responses simplified.

Latest version **2.0.1** (published 2017-12-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @repit/lambda-send
pnpm add @repit/lambda-send
yarn add @repit/lambda-send
bun add @repit/lambda-send
```

## 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 | 2.0.1 |
| Published | 2017-12-22 |
| First published | 2017-12-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ion Suman |
| Maintainers | sumanion |

## Links

- npm: https://www.npmjs.com/package/@repit/lambda-send
- npm.io page: https://npm.io/package/@repit/lambda-send

## Recent versions

- 2.0.1 (latest) — 2017-12-22
- 2.0.0 — 2017-12-21
- 1.0.1 — 2017-12-15
- 1.0.0 — 2017-12-15

## README

# Lambda Send

AWS Lambda responses simplified.

## Installation

```bash
$ npm install @repit/lambda-send --save
```

## Usage

```js
'use strict'

const send = require('@repit/lambda-send')

exports.handler = (event, context, callback) => {
  // Send a default success response.
  send(callback, 200)

  // Send a custom success message.
  send(callback, 200, 'All right.')

  // Send a custom success message.
  send(callback, 200, {
    countryCode: 'US'
  })

  // Send a default error response.
  send(callback, 400)

  // Send a custom error response.
  send(callback, 400, 'Something went wrong.')

  // Send a custom error response.
  send(callback, 400, {
    reason: 'Something went wrong.'
  })

  // Disable CORS.
  send(callback, 200, null, {
    cors: false // Default: true.
  })

  // Send custom headers.
  send(callback, 200, null, {
    headers: {
      //
    }
  })

  // Add properties to the response body.
  send(callback, 200, null, {
    body: {
      //
    }
  })
}
```


## Response Structure

- Success response:

```js
{
  "ok": true, // statusCode === 200
  "payload": null || <user defined payload>,
  <user defined property name>: <user defined property value>
}
```

- Error response:

```js
{
  "ok": false, // statusCode !== 200
  "code": <user defined status code>,
  "payload": "Resource is not available." || <user defined payload>,
  <user defined property name>: <user defined property value>
}
```

## Testing

```bash
$ npm test
```

## License

MIT

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