1.0.2 • Published 6 years ago
bamboo-lambda v1.0.2
Bamboo Lambda
Our serverless stack.
Setup
yarn install
- install the dependenciescp 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 runyarn deploy
Scripts
yarn dev
starts what you need to begin developingyarn test:unit
executes the unit testsyarn 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 onceyarn test:unit:watch
exectutes unit tests in watch modeyarn log FUNCTION
starts logging the function nameyarn invoke FUNCTION
calls the function and returns the logsyarn deploy:only FUNCTION
deploys just that function, useful for rapid iterative developmentyarn deploy
deploys the entire serverless stack and runs some post-deploy scriptsyarn pretty
runs prettier on the whole project, make sure you commit before running this so not to confuse your commityarn 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}
fromserverless.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
CLIENT => 2) GATEWAY => 3) HANDLER => 4) DOMAIN => 5) HANDLER => 6) GATEWAY => 7) CLIENT
Client initiates a request to the gateway
- Gateway authorizes the request and passes to the lambda handler
- Handler validates input and translates into a strong type before passing to the domain
- Domain performs the actual logic for the call, can be assured that the input has been validated
- Handler translates the domain response into the expected response from client
- Response passes back through gateway before..
- Client recieves response
Visual Studio Code
If you are using Visual Studio code for editing we have some reccomended extensions and settings:
Extensions
- Blueprint - for templating (see blueprint-templates dir)
- vscode-icons - for better icons in vscode
- Prettier - for better icons in vscode
Other
- To build the
cognito-user-pool.yml
I ranaws 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
1.0.2
6 years ago