# api-gateway-mapping-template

> Make AWS API Gateway's Mapping Template testable.

Latest version **0.0.8** (published 2020-04-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install api-gateway-mapping-template
pnpm add api-gateway-mapping-template
yarn add api-gateway-mapping-template
bun add api-gateway-mapping-template
```

## 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.8 |
| Published | 2020-04-29 |
| First published | 2015-12-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 33.4 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 40 |
| Author | Takatoshi Matsumoto |
| Maintainers | toqoz |

## Links

- npm: https://www.npmjs.com/package/api-gateway-mapping-template
- Repository: https://github.com/ToQoz/api-gateway-mapping-template
- Homepage: https://github.com/ToQoz/api-gateway-mapping-template#readme
- Issues: https://github.com/ToQoz/api-gateway-mapping-template/issues
- npm.io page: https://npm.io/package/api-gateway-mapping-template

## Dependencies (3)

- [clone](https://npm.io/package/clone.md) ^1.0.2
- [JSONPath](https://npm.io/package/JSONPath.md) ^0.11.2
- [velocityjs](https://npm.io/package/velocityjs.md) ^0.7.4

## Recent versions

- 0.0.8 (latest) — 2020-04-29
- 0.0.7 — 2015-12-19
- 0.0.6 — 2015-12-18
- 0.0.5 — 2015-12-18
- 0.0.4 — 2015-12-15
- 0.0.3 — 2015-12-15
- 0.0.2 — 2015-12-14
- 0.0.1 — 2015-12-13

## README

# api-gateway-mapping-template

make AWS API Gateway's Mapping Template testable

![Image](http://toqoz.net/art/images/api-gateway-mapping-template.png)

## Installation

```
npm install api-gateway-mapping-template
```

## Usage

simple.js:

```node
var mappingTemplate = require('api-gateway-mapping-template')

var vtl = '$input.json(\'$.data\')';
var payload = '{"data": {"url": "https://github.com/ToQoz/api-gateway-mapping-template"}}';

var result = mappingTemplate({template: vtl, payload: payload})
console.dir(result);
```

***

```
$ node ./simple.js
'{"url":"https://github.com/ToQoz/api-gateway-mapping-template"}'
```

## Examples

- [ToQoz/api-gateway-localdev](https://github.com/ToQoz/api-gateway-localdev) - simulate API Gateway + Lambda in your local.
- [online checker](https://github.com/ToQoz/mapping-template-checker.toqoz.net) - http://mapping-template-checker.toqoz.net

## API

```node
var mappingTemplate = require('api-gateway-mapping-template')
```

### mappingTemplate(parameters)

This function renders AWS API Gateway's Mapping Template by using given payload, params and context.

- Arguments
  - parameters - **required** - `map`
      - template - **required** - `String|Buffer`
      - payload - **required** - `String|Buffer`
      - params - `map`
        - path - `map<String, String|Number|Boolean|null>`
        - querystring - `map<String, String|Number|Boolean|null>`
        - header - `map<String, String|Number|Boolean|null>`
      - context - `map`
        - indentity - `map<String, String>`
          - cognitoAuthenticationType - `String`
          - cognitoIdentityId - `String`
          - cognitoIdentityPoolId - `String`
          - sourceIp - `String`
          - user - `String`
          - userAgent - `String`
          - userArn - `String`
        - requestId - `String`
        - resourceId - `String`
        - resourcePath -  `String`
        - stage -  `String`
- Return value
  - rendered template -  `String`

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