# bamboo-lambda

> Bamboos Serverless Stack

Latest version **1.0.2** (published 2018-11-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install bamboo-lambda
pnpm add bamboo-lambda
yarn add bamboo-lambda
bun add bamboo-lambda
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-11-10 |
| First published | 2018-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 16 |
| Unpacked size | 705.8 KB |
| Known vulnerabilities | 0 (+4 in 4 direct dependencies) |
| Install scripts | no |
| Author | getbamboo.io |
| Maintainers | bamboo-ci-user |

## Links

- npm: https://www.npmjs.com/package/bamboo-lambda
- npm.io page: https://npm.io/package/bamboo-lambda

## Dependencies (16)

- [uuid](https://npm.io/package/uuid.md) ^3.3.2
- [ramda](https://npm.io/package/ramda.md) ^0.25.0
- [moment](https://npm.io/package/moment.md) ^2.22.2
- [bravent](https://npm.io/package/bravent.md) ^0.1.0
- [dynamoose](https://npm.io/package/dynamoose.md) ^0.8.7
- [ntp-client](https://npm.io/package/ntp-client.md) ^0.5.3
- [query-string](https://npm.io/package/query-string.md) ^6.1.0
- [path-to-regexp](https://npm.io/package/path-to-regexp.md) ^2.4.0
- [class-validator](https://npm.io/package/class-validator.md) ^0.8.5
- [data.validation](https://npm.io/package/data.validation.md) ^1.3.1
- [basiq-sdk-nodejs](https://npm.io/package/basiq-sdk-nodejs.md) ^1.0.5
- [isomorphic-fetch](https://npm.io/package/isomorphic-fetch.md) ^2.2.1
- [ts-retry-promise](https://npm.io/package/ts-retry-promise.md) ^0.2.0
- [class-transformer](https://npm.io/package/class-transformer.md) ^0.1.9
- [source-map-support](https://npm.io/package/source-map-support.md) ^0.5.0
- [@aws/dynamodb-auto-marshaller](https://npm.io/package/@aws/dynamodb-auto-marshaller.md) ^0.7.1

## Recent versions

- 1.0.2 (latest) — 2018-11-10

## README

# Bamboo Lambda

Our serverless stack.

# Setup

- `yarn install` - install the dependencies
- `cp src/config/example.local.config.json src/config/local.config.json` to setup the config then fill in the bits. You may need API keys from one of the other devs. The rest of the config values will be set automatically after you first run `yarn deploy`

# Scripts

- `yarn dev` starts what you need to begin developing
- `yarn test:unit` executes the unit tests
- `yarn test:integration` executes the integration tests (against the actual server)
- `yarn test:integration:only TEST` executes just that one test (or group of tests if you use describe())
- `yarn test:integration:quick` executes all integration tests except for some that take a long time (Basiq)
- `yarn test` executes all tests once
- `yarn test:unit:watch` exectutes unit tests in watch mode
- `yarn log FUNCTION` starts logging the function name
- `yarn invoke FUNCTION` calls the function and returns the logs
- `yarn deploy:only FUNCTION` deploys just that function, useful for rapid iterative development
- `yarn deploy` deploys the entire serverless stack and runs some post-deploy scripts
- `yarn pretty` runs prettier on the whole project, make sure you commit before running this so not to confuse your commit
- `yarn set:stage STAGE` will update your local config with the parameters pulled from cloud formation (you need the AWS CLI installed for this)

# Testing

- There are unit test which run before the build and are run in watch mode as part of `yarn dev`. These should test internal business logic
- Integration tests after deploy and make actual calls to the server to test end-to-end functionality
- If you need to see what fetch calls are being made in your `src/config/local.config.json` add `"LOG_FETCH": true,` and now fetch calls should be logged to the console.

# Deploying - READ!!

- There is a known issue currently with deploying new stack. If you are deploying for the first time you will get errors unless you comment out the line that reads `AWS_USER_POOL_ID: ${cf:${self:custom.stackName}.UserPoolId}` from `serverless.yml`. This is because we are trying to get the UserPoolID from the current stack, but it needs the stack to be deployed already before it can do that. On the second deploy you can put the line back in again and it should be fine. This is a known issue and we are trying to work through it on this issue: https://github.com/serverless/serverless/issues/4940

# Coding Standards

- This project runs a pre-commit git hook that executes "prettier" on changed files to ensure a common coding standard

# Request Response Flow

1.  CLIENT => 2) GATEWAY => 3) HANDLER => 4) DOMAIN => 5) HANDLER => 6) GATEWAY => 7) CLIENT

1.  Client initiates a request to the gateway
1.  Gateway authorizes the request and passes to the lambda handler
1.  Handler validates input and translates into a strong type before passing to the domain
1.  Domain performs the actual logic for the call, can be assured that the input has been validated
1.  Handler translates the domain response into the expected response from client
1.  Response passes back through gateway before..
1.  Client recieves response

# Visual Studio Code

If you are using Visual Studio code for editing we have some reccomended extensions and settings:

## Extensions

- [Blueprint](https://marketplace.visualstudio.com/items?itemName=teamchilla.blueprint) - for templating (see blueprint-templates dir)
- [vscode-icons](https://marketplace.visualstudio.com/items?itemName=robertohuertasm.vscode-icons) - for better icons in vscode
- [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) - for better icons in vscode

# Other

- To build the `cognito-user-pool.yml` I ran `aws cognito-idp describe-user-pool --region ap-southeast-2 --user-pool-id ap-southeast-2_aaWkuRqqc` then copied over the result
- We are using `--forceExit` on the integration tests because of this issue in jest: https://github.com/facebook/jest/issues/6639

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