1.0.2 • Published 7 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.jsonto 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 devstarts what you need to begin developingyarn test:unitexecutes the unit testsyarn test:integrationexecutes the integration tests (against the actual server)yarn test:integration:only TESTexecutes just that one test (or group of tests if you use describe())yarn test:integration:quickexecutes all integration tests except for some that take a long time (Basiq)yarn testexecutes all tests onceyarn test:unit:watchexectutes unit tests in watch modeyarn log FUNCTIONstarts logging the function nameyarn invoke FUNCTIONcalls the function and returns the logsyarn deploy:only FUNCTIONdeploys just that function, useful for rapid iterative developmentyarn deploydeploys the entire serverless stack and runs some post-deploy scriptsyarn prettyruns prettier on the whole project, make sure you commit before running this so not to confuse your commityarn set:stage STAGEwill 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.jsonadd"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.ymlI ranaws cognito-idp describe-user-pool --region ap-southeast-2 --user-pool-id ap-southeast-2_aaWkuRqqcthen copied over the result - We are using
--forceExiton the integration tests because of this issue in jest: https://github.com/facebook/jest/issues/6639
1.0.2
7 years ago