1.0.0 • Published 7 years ago
lambdab v1.0.0
Lambdab
A wrapper for HTTP lambdas.
How to Use
// HTTP 200 - "Hello World"
module.exports.handler = new Lambdab(function(event) {
return "Hello World"
})// HTTP 500 - "Something went wrong." (logs the actual error)
module.exports.handler = new Lambdab(function(event) {
throw new Error()
})// HTTP 400 - "Request is not valid JSON"
module.exports.handler = new Lambdab(function(event) {
throw new Lambdab.UserError("Request is not valid JSON")
})// One second - HTTP 200 - "Hello World"
module.exports.handler = new Lambdab(async function(event) {
await new Timeout(1000)
return "Hello World"
})Lambdab.headers["Access-Control-Allow-Origin"] = "*"Body is always JSON-ified.
1.0.0
7 years ago