# @softchef/cdk-restapi

> Easy to manage Rest-API

Latest version **2.0.183** (published 2022-11-10) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @softchef/cdk-restapi
pnpm add @softchef/cdk-restapi
yarn add @softchef/cdk-restapi
bun add @softchef/cdk-restapi
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score; declining downloads.

## Facts

| | |
|---|---|
| Version | 2.0.183 |
| Published | 2022-11-10 |
| First published | 2021-06-02 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 197.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | SoftChef |
| Maintainers | softchef-iot-lab |
| Keywords | aws, cdk, restapi |

## Links

- npm: https://www.npmjs.com/package/@softchef/cdk-restapi
- Repository: https://github.com/softchef/cdk-restapi
- Homepage: https://github.com/softchef/cdk-restapi#readme
- Issues: https://github.com/softchef/cdk-restapi/issues
- npm.io page: https://npm.io/package/@softchef/cdk-restapi

## 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

- 2.0.183 (latest) — 2022-11-10
- 1.0.94 (cdkv1) — 2022-08-09
- 2.0.182 — 2022-08-09
- 2.0.181 — 2022-08-09
- 1.0.93 — 2022-08-08
- 2.0.180 — 2022-08-08
- 1.0.92 — 2022-08-07
- 2.0.179 — 2022-08-07
- 1.0.91 — 2022-08-06
- 2.0.178 — 2022-08-06
- 1.0.90 — 2022-08-05
- 2.0.177 — 2022-08-05
- 1.0.89 — 2022-08-04
- 2.0.176 — 2022-08-04
- 1.0.88 — 2022-08-03
- … 438 more at https://npm.io/package/@softchef/cdk-restapi/versions

## README

# AWS CDK with RestApi

[![npm version](https://badge.fury.io/js/%40softchef%2Fcdk-restapi.svg)](https://badge.fury.io/js/%40softchef%2Fcdk-restapi)
![Release](https://github.com/SoftChef/cdk-restapi/workflows/Release/badge.svg)
![npm](https://img.shields.io/npm/dt/@softchef/cdk-restapi?label=NPM%20Downloads&color=orange)

This construct is base on @aws/aws-apigateway.RestApi.

The RestApi has addResource & addMethod function to create REST API routes. But the source code are low readability about what kind of resources and method in the API. So this construct are redefine the resources to improve readability.

## Installation

```
  npm install @softchef/cdk-restapi
  // or
  yarn add @softchef/cdk-restapi
```

## Example
```
const demoRestApi = new RestApi(stack, 'RestApiDemo', {
  resources: [
    {
      path: '/articles',
      httpMethod: HttpMethod.GET,
      lambdaFunction: new lambda.NodejsFunction(stack, 'GetArticles', {
        entry: `./lambda-assets/articles/get-articles/app.ts`,
      }),
    },
    {
      path: '/articles',
      httpMethod: HttpMethod.POST,
      lambdaFunction: new lambda.NodejsFunction(stack, 'CreateArticle', {
        entry: `./lambda-assets/articles/create-article/app.ts`,
      }),
    },
    {
      path: '/articles/{articleId}',
      httpMethod: HttpMethod.GET,
      lambdaFunction: new lambda.NodejsFunction(stack, 'GetArticle', {
        entry: `./lambda-assets/articles/get-article/app.ts`,
      }),
    },
    {
      path: '/articles/{articleId}',
      httpMethod: HttpMethod.PUT,
      lambdaFunction: new lambda.NodejsFunction(stack, 'UpdateArticle', {
        entry: `./lambda-assets/articles/update-article/app.ts`,
      }),
    },
    {
      path: '/articles/{articleId}/comments',
      httpMethod: HttpMethod.GET,
      lambdaFunction: new lambda.NodejsFunction(stack, 'GetComments', {
        entry: `./lambda-assets/articles/get-comments/app.ts`,
      }),
    },
    {
      path: '/articles/{articleId}/comments',
      httpMethod: HttpMethod.POST,
      lambdaFunction: new lambda.NodejsFunction(stack, 'CreateComment', {
        entry: `./lambda-assets/articles/create-comment/app.ts`,
      }),
    },
  ],
  enableCors: true,
});

// Add multi-resources
demoRestApi.addResources([
  {
    path: '/authors',
    httpMethod: HttpMethod.GET,
    lambdaFunction: new lambda.NodejsFunction(stack, 'GetAuthors', {
      entry: `./lambda-assets/authors/get-authors/app.ts`,
    }),
  },
  {
    path: '/authors/{authorId}',
    httpMethod: HttpMethod.GET,
    lambdaFunction: new lambda.NodejsFunction(stack, 'GetAuthor', {
      entry: `./lambda-assets/authors/get-author/app.ts`,
    }),
  }
]);

// Add single resource
demoRestApi.addResource({
  path: '/authors',
  httpMethod: HttpMethod.POST,
  lambdaFunction: new lambda.NodejsFunction(stack, 'CreateAuthors', {
    entry: `./lambda-assets/authors/create-authors/app.ts`,
  }),
})

```



### Demo

1. Clone this repository
2. Run commands
```
npx projen
cdk deploy --app lib/demo/demo.js
```
3. Checkout the CloudFormation stacks and API Gateway

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