Lambda API: v0.9 Released
v0.9 adds new features to give developers better control over error handling and serialization. Plus TypeScript support and additional API Gateway inputs.
Lambda API v0.9 adds new features to give developers better control over error handling and serialization. A TypeScript declaration file has also been added along with some additional API Gateway inputs that are now available in the REQUEST object.
NPM: https://www.npmjs.com/package/lambda-api
GitHub: https://github.com/jeremydaly/lambda-api
New Error Types
Lambda API now provides several different types of errors that can be used by your application. RouteError, MethodError, ResponseError, and FileError will all be passed to your error middleware. ConfigurationErrors will throw an exception when you attempt to .run() your route and can be caught in a try/catch block. Most error types contain additional properties that further detail the issue.
1const errorHandler = (err,req,res,next) => {23 if (err.name === 'RouteError') {4 // do something with route error5 } else if (err.name === 'FileError') {6 // do something with file error7 }8 // continue9 next()10})
Custom Serializers
By default, Lambda API will serialize objects with JSON.stringify(). If you want more fine-grained control over serialization, you can now add a serializer property to the configuration options when instantiating the API.
1const api = require('lambda-api')({ 2 version: 'v1.0',3 serializer: myCustomSerializer4});
Additional API Gateway Inputs
Lambda API now passes through additional API Gateway inputs directly into the REQUEST object including pathParameters, stageVariables and isBase64Encoded.
TypeScript Support
Thanks to an incredible amount of work by @hassankhan, a TypeScript declaration file has been added to support your projects. Just import 'lambda-api' into your TypeScript handler.
1// import Lambda API and TypeScript declarations2import API from 'lambda-api'34// instantiate the API5const api = API({6 version: 'v1',7 logger: { level: 'debug' }8});
Full Release Notes: https://github.com/jeremydaly/lambda-api/releases/tag/v0.9.0
NPM: https://www.npmjs.com/package/lambda-api
GitHub: https://github.com/jeremydaly/lambda-api