@honestdoor/lambda-utils
v0.2.4
Published
> TODO: description
Downloads
4
Readme
@honestdoor/lambda-utils
Collection of helpful utilities around working with lambda functions
Response Builder
The Responder
is meant to make api gateway responses easier to write and manage
Example Usage:
import { Responder } from '@honestdoor/lambda-utils'
const res = new Responder({
// Default response variables
headers: {
"Access-Control-Allow-Origin": "locahost:3000"
},
statusCode: 400
})
...
const response = res.status(200).json({ success: true })
...
console.log(response)
Output:
{
"headers": {
"Access-Control-Allow-Origin": "locahost:3000"
},
"statusCode": 200,
"body": "{ success: true }"
}
Error Example:
res.status(400).error("Something went terribly wrong!")