# cdk-http-openapi

> CDK Construct that lets you build AWS Api Gateway Http Api, backed by Lambdas, based on a OpenAPI spec file.

Latest version **0.1.1** (published 2022-10-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install cdk-http-openapi
pnpm add cdk-http-openapi
yarn add cdk-http-openapi
bun add cdk-http-openapi
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2022-10-06 |
| First published | 2022-10-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 1 |
| Unpacked size | 1.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | iDanielBot |
| Maintainers | idanielbot |
| Keywords | cdk, openapi, lambda, API, Api Gateway, http, constructs, reusable cdk constructs |

## Links

- npm: https://www.npmjs.com/package/cdk-http-openapi
- Repository: https://github.com/iDanielBot/cdk-http-openapi
- Issues: https://github.com/iDanielBot/cdk-http-openapi/issues
- npm.io page: https://npm.io/package/cdk-http-openapi

## Dependencies (1)

- [yaml](https://npm.io/package/yaml.md) ^2.1.3

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2022-10-06
- 0.1.0 — 2022-10-06
- 0.0.3 — 2022-10-06
- 0.0.2 — 2022-10-05
- 0.0.1 — 2022-10-05

## README

# cdk-http-openapi

CDK Construct that lets you build AWS Api Gateway Http Api, backed by Lambdas, based on a OpenAPI spec file.


# Features

[] Deploy Api Gateway Http Api based on a OpenAPI spec file.
[] Each API Route will be backed by 1 NodeJS lambda.
[] Configure CORS for your API.
[] Add custom domain (eg: https://my-awesome-api.my-domain.com) to your API.
[] Enable custom authorizers to Http Api Lambda integrations.
[] Customize your lambdas's memory, timeouts, log retention, env variables and other stuff.


# Setup

Add latest package to your project with npm/yarn

```bash
npm i --save cdk-http-openapi
yarn add -D cdk-http-openapi
```


# Start using cdk constructs in your infrastructure definition <br>Examples

```typescript
import { HttpOpenApi } from 'cdk-http-openapi'

// ... in your stack definition
const api = new HttpOpenApi(this, 'MyApi', {
    serviceName: 'my-service',
    openApiSpec: './openapi.yml',
    lambdasSourcePath: './dist/src' // optional. It defaults to './.build/src'
    integrations: [
        {
            operationId: 'getEntity', // for each operation you define in your OpenAPI spec
            handler: 'api.getEntity', // you can register a lambda handler to handle your http request
        },
        {
            operationId: 'storeEntity',
            handler: 'api.storeEntity',
            timeoutSeconds: 5,
            memorySize: 512,
            env: { 
                DB_HOST: '...',
                DB_USERNAME: '...',
                DB_PASSWORD: '...'
            },
        }
    ]
});

const domainName = 'my-awesome-api.cool.io';
const certificateArn = `arn:aws:acm:${AWS_REGION}:${AWS_ACCOUNT}:certificate/${CERTIFICATE_ID}`;
const hostedZone = 'cool.io';

api.enableCustomDomain({domainName, certificateArn, hostedZone});

```

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