An opinionated starter kit by orangejellyfish for Serverless framework apps running in AWS. Built to be future-proof. Inspired by and adapted from the excellent serverless-babel-starter project by Postlight.
-
Lambdas run Node 8 by default making your functions faster and giving you the ability to use more recent ECMAScript features including async/await.
-
Lambda code is bundled with Webpack 4 via the serverless-webpack plugin, reducing the amount of code deployed to AWS.
-
Lambda code is compiled with Babel 7 and babel-preset-env, meaning you can use even more cutting-edge ECMAScript features if you need to, without unnecessarily compiling code that would be supported by Node 8.
-
Lambda config is located alongside the function code and referenced from the top-level Serverless configuration file, offering greater separation of concerns and keeping the configuration file readable.
-
IAM roles are configured per-Lambda via the serverless-iam-roles-per-function plugin, meaning functions better follow the principle of least privilege and are therefore more secure.
-
API Gateway request logging into CloudWatch is enabled by default, meaning it will be easier to trace requests through the system, leading to more convenient debugging.
-
A "run warm" utility which can be used as a higher order function by any Lambda function handler to keep the container alive, avoiding the cold start performance problem.
-
Jest support for unit testing, gathering coverage information by default.
-
ESLint, Husky and lint-staged config for greater code consistency.
-
Local AWS Lambda and API Gateway emulation via the serverless-offline plugin.
You can use the Serverless CLI to scaffold a new project from this starter kit:
serverless create --template-url https://github.com/orangejellyfish/serverless-starter --path your/local/path
WARNING: More than one matching handlers found for 'src/functions/hello/index'. Using 'src/functions/hello/index.js'.
This warning is logged by serverless-webpack when bundling the Lambda function code. It happens because the plugin detects another file in the same directory with a similar name. The other file is the unit test file. The warning can be safely ignored. See this issue for more information.