# aws-apigateway-importer

> API Gateway Swagger Importer

Latest version **0.8.0** (published 2016-03-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install aws-apigateway-importer
pnpm add aws-apigateway-importer
yarn add aws-apigateway-importer
bun add aws-apigateway-importer
```

## 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.8.0 |
| Published | 2016-03-04 |
| First published | 2016-01-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Jay Morrow |
| Maintainers | jaymorrow |
| Keywords | aws, apigateway, api, gateway, swagger, importer |

## Links

- npm: https://www.npmjs.com/package/aws-apigateway-importer
- Repository: https://github.com/jaymorrow/node-aws-apigateway-importer
- Homepage: https://github.com/jaymorrow/node-aws-apigateway-importer#readme
- Issues: https://github.com/jaymorrow/node-aws-apigateway-importer/issues
- npm.io page: https://npm.io/package/aws-apigateway-importer

## Dependencies (4)

- [async](https://npm.io/package/async.md) ^1.5.2
- [extend](https://npm.io/package/extend.md) ^3.0.0
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.2.30
- [loglevel](https://npm.io/package/loglevel.md) ^1.4.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.8.0 (latest) — 2016-03-04
- 0.7.4 — 2016-02-22
- 0.7.3 — 2016-01-28
- 0.7.2 — 2016-01-27
- 0.7.1 — 2016-01-26
- 0.7.1-1 — 2016-01-26
- 0.7.1-0 — 2016-01-26
- 0.7.0 — 2016-01-26
- 0.7.0-1 — 2016-01-26
- 0.8.0-0 — 2016-01-26
- 0.7.0-0 — 2016-01-26
- 0.6.2 — 2016-01-22
- 0.6.1 — 2016-01-21
- 0.6.0 — 2016-01-21
- 0.6.0-0 — 2016-01-20
- … 6 more at https://npm.io/package/aws-apigateway-importer/versions

## README

# aws-apigateway-importer

[![Circle CI](https://circleci.com/gh/jaymorrow/node-aws-apigateway-importer.svg?style=shield)](https://circleci.com/gh/jaymorrow/node-aws-apigateway-importer)
[![Test Coverage](https://codeclimate.com/github/jaymorrow/node-aws-apigateway-importer/badges/coverage.svg)](https://codeclimate.com/github/jaymorrow/node-aws-apigateway-importer/coverage)
[![Code Climate](https://codeclimate.com/github/jaymorrow/node-aws-apigateway-importer/badges/gpa.svg)](https://codeclimate.com/github/jaymorrow/node-aws-apigateway-importer)

Not quite port of [aws-apigateway-importer](https://github.com/awslabs/aws-apigateway-importer) for Node. It's still very limited in that it will only wholesale import/delete APIs, it also will only handle [Swagger](http://swagger.io/) JSON files.

## Usage

See the _example_ folder included in the repo for the swagger.json file.

```js
var ApiImporter = require('aws-apigateway-importer');
var importer = new ApiImporter('swagger.json');

importer.create(function (err, result) {
  if (err) {
    return console.error(err);
  }

  importer.deploy(function (err, result) {
    if (err) {
      return console.error(err);
    }
    console.log(result);
  });
});
```

If at anytime the deployment is unsuccessful due to an error the partially created API will be deleted.

## Methods

### new constructor(doc[, options])

Reads the swagger json file and prepares the contents for API creation.

#### Arguments
1. __doc__ (_String_ | _Object_): The path to the Swagger file of a JavaScript object that has the same format as a swagger file.
2. [__options__] \(_Object_): Configuration options for the AWS ApiGateway service.
    * loglevel (_String_): `debug`, `info`, `error`. See [Loglevel](http://pimterry.github.io/loglevel/) for more information.
    * delay (_Number_): The time in milliseconds to wait between adding integrations and responses to resources.
    * apigateway (_Object_): Any option available on the [API Gateway constructor](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/APIGateway.html#constructor-property).

### create(callback)

Creates the full API (methods, integrations, etc), but does not deploy it to a server. The API name is pulled from `info.title` in the swagger.json file.

#### Arguments
1. __callback(err, result)__ (_Function_): Run after creation. 

### deploy(callback)

Deploys the API so that it is reachable via the internet. the `create` method must be called __before__ the `deploy` method.

The Stage name for the api is pulled from the `basePath` property of the swagger.json file and the leading `/` is removed.

#### Arguments
1. __callback(err, result)__ (_Function_): Run after deployment.

### updateApi(callback)

Deletes all methods and resources on an existing API and recreates it from the Swagger configuration. 

** Even if methods have the same path and signature they will have new resource IDs. This is a destructive operation for everything but the parent API. **

#### Arguments
1. __callback(err, result)__ (_Function_): Run after creation.

---
_Source: https://npm.io/package/aws-apigateway-importer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
