Socket
Socket
Sign inDemoInstall

lambda-serverless-api

Package Overview
Dependencies
Maintainers
1
Versions
396
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lambda-serverless-api - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

2

package.json

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc