JSPM

serverless-apigateway-route-settings

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 268
  • Score
    100M100P100Q97314F
  • License ISC

A Serverless Framework Plugin for configuring Route Settings for Api Gateway v2

Package Exports

  • serverless-apigateway-route-settings

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (serverless-apigateway-route-settings) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

serverless-apigateway-route-settings

CircleCI npm contributions welcome

About

A Serverless Framework Plugin which helps you configure route specific variables, such as *throttling rate limits, detailed metrics etc (see CloudFormation RouteSettings) for Api Gateway v2 (HTTP).

Note: Currently only works for Default Route Settings, I am hoping to allow route specific override in a future update.

Supported RouteSettings

ApiGateway v2 seems to only accept the following RouteSettings for Api Gateway v2 (HTTP):

  • ThrottlingBurstLimit
  • ThrottlingRateLimit
  • DetailedMetricsEnabled

Get Started

npm install serverless-apigateway-route-settings

Edit your serverless.yml to use this plugin:

plugins:
  - serverless-apigateway-route-settings

Next, edit your serverless.yml for DefaultRouteSettings

custom:
  httpApiRouteSettings:
    burstLimit: 200
    rateLimit: 400
    detailedMetricsEnabled: true

Caveats

  • Only DefaultRouteSettings are currently supported, I'm currently trying to get CloudFormation to work with RouteSettings for individual routes to override this.
  • Doesn't work with pre existing API Gateways, hoping to add support for this.

Example serverless.yml

service: example

frameworkVersion: '2'

plugins:
  - serverless-apigateway-route-settings

custom: 
  httpApiRouteSettings:
    detailedMetricsEnabled: true
    rateLimit: 200
    burstLimit: 30

provider:
  name: aws
  runtime: nodejs12.x

functions:
  # Inherits the default throttle rate limits.
  hello:
    handler: src/helloWorld.handler
    events:
      - httpApi:
          path: /hello
          method: GET

  # Overrides the default throttle rate limits.
  lowerRateLimit:
    handler: src/lowerRateLimit.handler
    events:
      - httpApi:
          path: /throttle
          method: GET