Lambda API: v0.5 Released

v0.5 takes advantage of AWS Lambda's recently released support for Node v8.10 and has removed its Bluebird promise dependency in favor of async/await. Lambda API is now faster and adds built-in CORS support, additional wildcard features, new HTTP header management methods and more.

Posted in #lambda-api

Lambda API v0.5 is here! There have been some exciting changes in the AWS serverless ecosystem in the last few months, but most importantly, support for Node v8.10! That means we can now use async/await instead of promises. This news prompted a rewrite of the core execution process to take advantage of the simplicity of async/await. This greatly simplified the code, removed the dependency on Bluebird, and made Lambda API even faster! Like sub-millisecond faster! 🏎

In addition to removing the Bluebird dependency, v0.5 adds a number of features to help solve additional use cases and speed up serverless development workflows. New built-in CORS support makes it easy to add default CORS headers with a single method call. Additional wildcard features have been added that allow specifying wildcards on nested routes, giving you more control over responding to OPTIONS requests. Several HTTP header management methods have been added including hasHeader(), getHeader(), and removeHeader(), as well as standardizing response header case to make management easier and comply with HTTP/2 standards.

Progress was also made on supporting additional standards such as HEAD requests. An alias was added to HEAD requests that will automatically match them to existing GET routes. This will then execute the route and return the headers without a body. There is more to be done here, but this is a step closer to meeting all the standards.

Lambda API's goal is to be a full-featured, lightweight web framework for your serverless applications. ⚡ If you have any feature requests, use case ideas, or other comments, please send me a message or post an issue on GitHub.



Built-In CORS Support

A convenience method named cors() is now available for adding CORS headers to responses. An optional options object can be passed in to customize the defaults.

The six defined CORS headers are as follows:

  • Access-Control-Allow-Origin (defaults to *)
  • Access-Control-Allow-Methods (defaults to GET, PUT, POST, DELETE, OPTIONS)
  • Access-Control-Allow-Headers (defaults to Content-Type, Authorization, Content-Length, X-Requested-With)
  • Access-Control-Expose-Headers
  • Access-Control-Max-Age
  • Access-Control-Allow-Credentials

The options object can contain the following properties that correspond to the above headers:

  • origin (string)
  • methods (string)
  • headers (string)
  • exposeHeaders (string)
  • maxAge (number in milliseconds)
  • credentials (boolean)

Defaults can be set by calling res.cors() with no properties, or with any combination of the above options.

res.cors({ origin: '', methods: 'GET, POST, OPTIONS', headers: 'Content-Type, Authorization', maxAge: 84000000 })

You can override existing values by calling res.cors() with just the updated values:

res.cors({ origin: '' })

HTTP Header Management

Three new HTTP header management methods have been added.


Retrieve the current header object or pass the optional key parameter and retrieve a specific header value. key is case insensitive.


Returns a boolean indicating the existence of key in the response headers. key is case insensitive.


Removes header matching key from the response headers. key is case insensitive. This method is chainable.

Release Notes:

Feature Release

v0.5 removes Bluebird dependency and adds built-in CORS support, additional wildcard features, new HTTP header management methods and more.

Remove Bluebird Dependency

  • Close #26 by removing Bluebird promises and replacing processing with async/await a524445
  • Remove node 6/7 tests in favor of native async/await support 6b9396b
  • Close #29 by upgrading all tests to async/await 8496285, 0d39e0b

Built-In CORS Support

Additional Wildcard Features

  • Close #20 with additional wildcard support 28fead2
  • Update wildcard documentation 5cfe0b3

HTTP Header Management Methods

  • Close #23 with new getHeader() method 22793a5
  • Add hasHeader and removeHeader, modify headers to lowercase b4caff9
  • Update tests with lowercase headers 1d8ec09
  • Add getHeader documentation 41ff595
  • Add header convenience methods documentation c4b768b

HEAD Method Aliasing

  • Close #19 by adding HEAD alias for GET requests 5fdcd32
  • Add HEAD tests and convert tests to async/await d12e2e9
  • Add documentation for HEAD method 045c052

General Updates

  • Change file structure to include lib directory 95a6cde
  • Update requires for lib dir structure b49f51a
  • Update test requires for new dir structure b96320b
  • Added default error on sendFile catch if not explicit dd147a3
  • Add .promise() to S3 getObject call 8eebc99
  • Update S3 tests with promise mock 728f892
  • Fix missing request object issue on request error f6e9577
  • Version bump and new package-lock.json file 4391d9e
  • Update license file with new date 3e7713f
  • Update aws-sdk version b16c1a6
  • Add tests for catching request errors c5872c3

Additional Documentation

Full Release Notes:



Comments are currently disabled, but they'll be back soon.