Lambda Boilerplate (Node)

Get started quick building and deploying a full Node.js application quick and painlessly on AWS Lambda

Features

✓ Author in ES2017 (including the unit tests)

✓ Export as ES5 & UMD

Mocha-Chai-Sinon testing stack

Basic Guide

Write your code in src/handlers.

Run npm run build to compile the source into ES5.

Put your unit tests in test. The npm test command runs the tests using Node.

npm Scripts

  • npm start - run development web server with api (default port 3000)
  • npm test - Lint the library and tests, then run the unit tests and generate coverage reports
  • npm run watch - Continuously run the unit tests as you make changes to the source and test files themselves
  • npm run lint - Lint the source and tests
  • npm run build - Transpile the library to ES5 in dist
  • npm run bundle - Build and generate distributable bundle.zip in project root

Linting

This boilerplate uses ESLint to lint your source. To change the rules, edit the .eslintrc files in the root directory, respectively.

Given that your unit tests typically follow different rules from your library code, it makes sense to lint them against a separate ESLint configuration. For this reason, a separate, unit-test specific .eslintrc can be found in the test directory.

FAQ

**What Babel features are supported?**

Nearly all Babel features should be supported by this boilerplate.

If you're using certain experimental features, like class properties, async-await, types, or decorators, then you'll need to install babel-eslint to use as the parser for ESLint.

If you're still getting an error, follow these steps:

  1. Double check to make sure that you're not typoing the new syntax ;)
  2. Determine what task is failing (for instance, is it ESLint?)
  3. Check that project's issue tracker to see if it is a known issue
  4. If it isn't, then open an issue here

Because of the fact that dependencies of this boilerplate, such as ESLint, are maintained by a team separate from Babel, there may be a delay between when a new feature is added to Babel and when those other libraries add support for it.

**What's the cost of transpiling?**

A thorough analysis of this question can be found here.

**How can I use this with React?**

Do you wish to use JSX? If the answer is no, then there is nothing that you need to do. If the answer is yes, then you need to install the babel-preset-react, and add it to your .babelrc file.

An example .babelrc file with this preset configured can be seen here.

**How can I export my library without the "default" property?**

As stated here, https://github.com/59naga/babel-plugin-add-module-exports:

Babel@6 doesn't export default module.exports any more So just npm install babel-plugin-add-module-exports --save-dev and then add it to your .babelrc file:

{
  "presets": [ "latest" ],
  "plugins": [
    "add-module-exports",
    "transform-es2015-modules-umd"
  ]
}