Skip to content
This repository has been archived by the owner on Mar 6, 2020. It is now read-only.

Latest commit

 

History

History
23 lines (12 loc) · 2.84 KB

dev.md

File metadata and controls

23 lines (12 loc) · 2.84 KB

DKT.flows-engine Development

Application Model & Resources

The flow-engine stack is defined with AWS SAM (Serverless Application Model). An AWS CloudFormation extension to simplify Stack-definitions of Serverless Applications. You can find the latest SAM template specification here.

The whole stack is basically a list of resources. All resources are defined in src/resources/. Every single resource requires a template.js file which exports a AWS SAM resource definition! If the resource is a AWS Lambda function then there should be a lambda directory containing the lambda function itself and all other modules, assets, etc. that are only required by the function. E.g. src/resources/<myResource>/lambda/index.js. Please check the AWS Lambda Getting Started Guide for more details about Lambda functions.

To create a unique ID for the template.js file you can use the command openssl rand -base64 14.

Lambdas can be written in ES6 including async functions. We Transform and bundle the Lambda function with webpack and babel using the latest preset. See the .babelrc file for details.
Check the compat-table for more details about which ES6/ES7 features are supported or not.

Resources with AWS::Serverless::Api Events

AWS SAM does not support CORS out of the box (yet). But it is possible to add CORS with a seperate Swagger api definition. There is a api_swagger_cors example you should check. But you have to do one more thing to make it work. For each Lambda that has a Serverless::Api event you must specify a AWS::Lambda::Permission resource. Our GraphQL resource is a working example for that.

Styleguide

We strongly recommend to install a realtime linter extension to your Editor. Otherwise you have to run npm run lint all the time. We're using ESLint with a slightly modified version of the Airbnb styleguide. Check the .eslintrc file for details.