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
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)
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.
methods: 'GET, POST, OPTIONS',
headers: 'Content-Type, Authorization',
You can override existing values by calling
res.cors() with just the updated values:
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.
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
- Remove node 6/7 tests in favor of native
- Close #29 by upgrading all tests to
Built-In CORS Support
Additional Wildcard Features
HTTP Header Management Methods
- Close #23 with new
removeHeader, modify headers to lowercase b4caff9
- Update tests with lowercase headers 1d8ec09
- Add header convenience methods documentation c4b768b
HEAD Method Aliasing
- Close #19 by adding
- Add HEAD tests and convert tests to
- Add documentation for
- 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
sendFilecatch if not explicit dd147a3
- 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
- Documentation updates d205646, c88de6b, eee50a4, 01f6285, 9b7449b
- Convert doc examples to arrow functions 2654ac5
Full Release Notes: https://github.com/jeremydaly/lambda-api/releases/tag/v0.5.0
Did you like this post? 👍 Do you want more? 🙌 Follow me on Twitter or check out some of the projects I’m working on. You can join my mailing list too. I’ll email you when I post more stuff like this! 📪