lambda-serverless-api
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -22,3 +22,3 @@ { | ||
}, | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"scripts": { | ||
@@ -25,0 +25,0 @@ "test": "grunt gardener", |
@@ -17,2 +17,4 @@ [![Build Status](https://img.shields.io/travis/simlu/lambda-serverless-api/master.svg)](https://travis-ci.org/simlu/lambda-serverless-api) | ||
- Parameter Validation and Response Generation | ||
- Generation of [Swagger](https://swagger.io/) Documentation | ||
- Rate Limiting using [lambda-rate-limiter](https://github.com/simlu/lambda-rate-limiter) | ||
@@ -36,7 +38,12 @@ - Logging of ApiErrors using [lambda-rollbar](https://github.com/simlu/lambda-rollbar) | ||
module.exports = api.wrap(process.env.RATE_LIMIT_PER_IP, () => { | ||
module.exports = api.wrap("POST register", [ | ||
api.Str("name", "json", false), | ||
api.Email("email", "json"), | ||
api.Str("password", "json") | ||
], process.env.RATE_LIMIT_PER_IP, ([name, email, password], context, callback, rb) => { | ||
// handle registration logic here ... | ||
if (new Date().getHours() === 4) { | ||
throw api.ApiError("I am a teapot", 418); | ||
} | ||
return api.JsonResponse({ message: "What's up?" }); | ||
return api.JsonResponse({ message: "Success!" }); | ||
}); | ||
@@ -47,4 +54,12 @@ | ||
The first `api.wrap` parameter defines the route and is re-declared in `serverless.yml`. | ||
A list of supported parameters can be found [here](lib/param.js). | ||
If you want to send plain text instead of json, you can use `ApiResponse`. | ||
## Swagger Documentation | ||
To generate swagger documentation we can call `api.generateSwagger()` after the api is initialized with routes. | ||
## Custom Error Messages | ||
@@ -51,0 +66,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13086
76