# json-config-lambda-handler

> Lambda function wrapper to load config from JSON environment variable (with optional KMS encryption)

Latest version **1.0.0** (published 2017-04-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install json-config-lambda-handler
pnpm add json-config-lambda-handler
yarn add json-config-lambda-handler
bun add json-config-lambda-handler
```

## 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.0 |
| Published | 2017-04-27 |
| First published | 2017-04-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Nicholas Penree |
| Maintainers | drudge |

## Links

- npm: https://www.npmjs.com/package/json-config-lambda-handler
- npm.io page: https://npm.io/package/json-config-lambda-handler

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^2.6.5
- [is-json](https://npm.io/package/is-json.md) ^2.0.1
- [aws-kms-decrypt-env](https://npm.io/package/aws-kms-decrypt-env.md) ^1.0.0

## Recent versions

- 1.0.0 (latest) — 2017-04-27
- 0.1.1 — 2017-04-27

## README

json-config-lambda-handler
==========================

```js
const withConfig = require('json-config-lambda-handler');

function handleEvent({ event, config }, callback) {
  console.log('event = ', event);
  console.log('config = ', config);
  callback(null);
}

exports.handle = withConfig(handleEvent);
```

# module.exports(handler)

* `handler` <[Function]> called when the handler is invoked
  * `args` <[Object]>
    * `event` <[Object]> AWS Lambda uses this parameter to pass in event data to the handler
    * `context` <[Context Object]> AWS Lambda context object
    * `config` <[Object]> parsed JSON configuration
  * `callback` <[Function]> invoke to return info back to caller
    * `error` <[Error]> an optional parameter that you can use to provide results of the failed Lambda function execution. When a Lambda function succeeds, you can pass null as the first parameter.
    * `result` <[Object]> an optional parameter that you can use to provide the result of a successful function execution. The result provided must be JSON.stringify compatible. If an error is provided, this parameter is ignored.

# module.exports(environmentVariable, handler)
* `environmentVariable` <[String]> an optional parameter containing environment variable name used to store the configuration. If not used, a default value of `CONFIG` is used.
* `handler` <[Function]> called when the handler is invoked
  * `args` <[Object]>
    * `event` <[Object]> AWS Lambda uses this parameter to pass in event data to the handler
    * `context` <[Context Object]> AWS Lambda context object
    * `config` <[Object]> parsed JSON configuration
  * `callback` <[Function]> invoke to return info back to caller
    * `error` <[Error]> an optional parameter that you can use to provide results of the failed Lambda function execution. When a Lambda function succeeds, you can pass null as the first parameter.
    * `result` <[Object]> an optional parameter that you can use to provide the result of a successful function execution. The result provided must be JSON.stringify compatible. If an error is provided, this parameter is ignored.

[Function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function
[String]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
[Object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
[Error]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
[Context Object]: http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html

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