# aws-scud

> scud - simple cloud usable daemon

Latest version **0.3.1** (published 2021-10-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install aws-scud
pnpm add aws-scud
yarn add aws-scud
bun add aws-scud
```

## Health

**Score 40/100 (D)** — status: abandoned.

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

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2021-10-19 |
| First published | 2020-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 40.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | fog-fish |

## Links

- npm: https://www.npmjs.com/package/aws-scud
- Repository: https://github.com/fogfish/scud
- Homepage: https://github.com/fogfish/scud#readme
- Issues: https://github.com/fogfish/scud/issues
- npm.io page: https://npm.io/package/aws-scud

## Dependencies (9)

- [@types/node](https://npm.io/package/@types/node.md) 16.11.1
- [aws-cdk-pure](https://npm.io/package/aws-cdk-pure.md) ^1.3.22
- [@aws-cdk/core](https://npm.io/package/@aws-cdk/core.md) *
- [@aws-cdk/aws-logs](https://npm.io/package/@aws-cdk/aws-logs.md) *
- [@aws-cdk/aws-lambda](https://npm.io/package/@aws-cdk/aws-lambda.md) *
- [@aws-cdk/aws-cognito](https://npm.io/package/@aws-cdk/aws-cognito.md) *
- [@aws-cdk/aws-route53](https://npm.io/package/@aws-cdk/aws-route53.md) *
- [@aws-cdk/aws-apigateway](https://npm.io/package/@aws-cdk/aws-apigateway.md) *
- [@aws-cdk/aws-route53-targets](https://npm.io/package/@aws-cdk/aws-route53-targets.md) *

## Recent versions

- 0.3.1 (latest) — 2021-10-19
- 0.3.0 — 2021-08-13
- 0.2.2 — 2021-05-11
- 0.2.1 — 2021-02-15
- 0.2.0 — 2021-02-14
- 0.1.2 — 2020-12-30
- 0.1.1 — 2020-12-30
- 0.1.0 — 2020-12-12

## README

# scud

`scud` is a Simple Cloud Usable Daemon for serverless RESTful API development. 
This library is AWS CDK pattern that takes care about infrastructure boilerplate so that you focuses on development of application logic. 

[![Build Status](https://github.com/fogfish/scud/workflows/build/badge.svg)](https://github.com/fogfish/scud/actions/)
[![Git Hub](https://img.shields.io/github/last-commit/fogfish/scud.svg)](https://github.com/fogfish/scud)
[![Coverage Status](https://coveralls.io/repos/github/fogfish/scud/badge.svg?branch=main)](https://coveralls.io/github/fogfish/scud?branch=main)
[![npm](https://img.shields.io/npm/v/aws-scud)](https://www.npmjs.com/package/aws-scud)


## Inspiration

AWS API Gateway and AWS Lambda is a perfect approach for quick prototyping or production development of microservice on Amazon Web Services. Unfortunately, it requires a boilerplate AWS CDK code to bootstrap the development. This library implements a high-order components on top of AWS CDK that hardens the api pattern

![RESTful API Pattern](scud.svg "RESTful API Pattern")

The library helps with
* building of lambda functions by integrating "compilation" process within cdk workflows. The following languages are supported:
  - [x] Golang
  - [ ] TypeScript
* integrates validation of OAuth2 Bearer token for each API endpoint


## Getting started

The latest version of the library is available at its `main` branch. All development, including new features and bug fixes, take place on the `main` branch using forking and pull requests as described in contribution guidelines.

```
npm install --save aws-scud
```

### Example RESTful API 

```ts
import * as api from '@aws-cdk/aws-apigateway'
import * as lambda from '@aws-cdk/aws-lambda'
import * as scud from 'scud'
import * as pure from 'aws-cdk-pure'

// 1. declare lambda function
const MyFun = (): lambda.FunctionProps =>
  scud.handler.Go({
    sourceCodePackage: path.join(__dirname, '.'),
    sourceCodeLambda: 'myfun',
    /* optionally other lambda.FunctionProps */
  })

// 2. declare api gateway
const Gateway = (): api.RestApiProps =>
  scud.Gateway({
    restApiName: 'example',
    /* optionally other api.RestApiProps */
  })

// 3. assembles RESTful api service from gateway and lambda functions
const service = scud.mkService(Gateway)
  .addResource('hello', scud.aws.Lambda(MyFun))

// 4. injects the service to stack
const stack = new cdk.Stack(/* ... */)
pure.join(stack, service)
```

Please see the RESTful API templates, clone them to draft a new microservice in matter of minutes:
* [blueprint-serverless-golang](https://github.com/fogfish/blueprint-serverless-golang)


### Example RESTful API with Domain Name

Supply custom domain name and ARN of Certificate

```ts
const service = scud.mkService(Gateway)
  .configRoute53('test.example.com', 'arn:aws:acm:eu-west-1:000000000000:certificate/00000000-0000-0000-0000-000000000000')
```


### Example protect RESTful API with OAuth2

The construct supports integration with AWS Cognito, the integration of AWS API Gateway and AWS Cognito is well depicted by [official documentation](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-integrate-with-cognito.html). The pattern enables deployment of this configuration, just supply ARN of user pool and supply scopes to protect endpoints 

```ts
const service = scud.mkService(Gateway)
  .configOAuth2([ "arn:aws:cognito-idp:..." ])
  .addResource('hello', scud.aws.Lambda(MyFun), ["my/scope"])
```

## HowTo Contribute

The project is [MIT](https://github.com/fogfish/scud/blob/master/LICENSE) licensed and accepts contributions via GitHub pull requests:

1. Fork it and clone 
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

```bash
git clone https://github.com/fogfish/scud
cd scud

npm install
npm run build
npm run test
npm run lint
```

## License

[![See LICENSE](https://img.shields.io/github/license/fogfish/scud.svg?style=for-the-badge)](LICENSE)

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