# phat-event-middy-lambda-middleware

Latest version **0.0.1** (published 2019-11-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install phat-event-middy-lambda-middleware
pnpm add phat-event-middy-lambda-middleware
yarn add phat-event-middy-lambda-middleware
bun add phat-event-middy-lambda-middleware
```

## 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.0.1 |
| Published | 2019-11-24 |
| First published | 2019-11-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | loujaybee |

## Links

- npm: https://www.npmjs.com/package/phat-event-middy-lambda-middleware
- Repository: https://github.com/loujaybee/phat-event-middy-lambda-middleware
- Homepage: https://github.com/loujaybee/phat-event-middy-lambda-middleware#readme
- Issues: https://github.com/loujaybee/phat-event-middy-lambda-middleware/issues
- npm.io page: https://npm.io/package/phat-event-middy-lambda-middleware

## Dependencies (1)

- [phat-event](https://npm.io/package/phat-event.md) ^1.1.2

## Recent versions

- 0.0.1 (latest) — 2019-11-24

## README

# phat-event-middy-lambda-middleware

A middlware in middy format that bootstraps phatEvent in an opinionated way. 

For more about phat-event check out [phat-event](https://github.com/loujaybee/phat-event)

What it does:

* Adds lambda "event" object to phat event
* Adds lambda "context" object to phat event
* Emits the log event on failure, or success
* Binds the error to the logEvent on failure
* Binds phatEvent instance to context, for re-use throughout the lambda

### Get Started


```javascript
const middy = require('middy')
const phatEventMiddleware = require('phat-event-middy-lambda-middleware');
const { logger } = require('./utils/logger')

const originalHandler = async function (event, _, callback) {
  callback(null, true)
}

const handler = middy(originalHandler).use(phatEventMiddleware({ log: logger }))

module.exports = { handler }

```

### onSuccess

The resultant phat event is: 

```javascript
{
  event: ...,
  context: ...,
  success: true
}
```

### onFailure

The resultant phat event is: 

```javascript
{
  event: ...,
  context: ...,
  success: false
}
```

---
_Source: https://npm.io/package/phat-event-middy-lambda-middleware · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
