npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

apex-apigateway

v0.1.6

Published

Deploy your Apex project on AWS API Gateway using Swagger configuration

Downloads

7

Readme

#apex-apigateway

Deploy your Apex project on AWS API Gateway using Swagger configuration

##Installation

npm install -g apex-apigateway

Usage

Usage: /usr/local/bin/apex-apigateway <command> [options]

Commands:
  create <name> [description]  Create a new RestAPI on AWS API Gateway
  deploy                       Update RestAPI with the new Swagger definitions
  list                         List RestAPI

Options:
  --help  Show help                                                    [boolean]

create

/usr/local/bin/apex-apigateway create <name> [description]

Options:
  --help       Show help                                               [boolean]
  --clone, -c  The ID of the RestAPI that you want to clone from.       [string]
  --force, -f  Force creating RestAPI.
               Overriding existing configuration.                      [boolean]

deploy

/usr/local/bin/apex-apigateway deploy

Options:
  --help        Show help                                              [boolean]
  --stage, -s   API-Gateway Stage Name         [string] [default: "development"]
  --alias, -a   Lambda Alisa Name                                       [string]
  --stdout, -o  Output Swagger                                         [boolean]

configuration

project.json

{
  "x-api-gateway": {
    "rest-api-id": "9siwjdu882",
    "swagger-func-template": {
      "consumes": ["application/json"],
      "produces": ["application/json"],
      "responses": {
        "200": {
          "description": "200 response",
          "schema": {
            "$ref": "#/definitions/Empty"
          },
          "headers": {
            "Access-Control-Allow-Headers": {
              "type": "string"
            },
            "Access-Control-Allow-Methods": {
              "type": "string"
            },
            "Access-Control-Allow-Origin": {
              "type": "string"
            }
          }
        },
        "400": {
          "description": "400 response"
        }
      },
      "x-amazon-apigateway-binary-media-types": ["application/json"],
      "x-amazon-apigateway-integration": {
        "responses": {
          "default": {
            "statusCode": "200",
            "responseParameters": {
              "method.response.header.Access-Control-Allow-Origin": "'*'"
            }
          },
          "(.*)(Error|Exception|errorMessage)(.*)": {
            "statusCode": "400"
          }
        },
        "requestTemplates": {
          "application/json": "{\n   \"method\": \"$context.httpMethod\",\n   \"body\" : $input.json('$'),\n   \"headers\": {\n     #foreach($param in $input.params().header.keySet())\n     \"$param\": \"$util.escapeJavaScript($input.params().header.get($param))\" #if($foreach.hasNext),#end\n \n     #end\n   },\n   \"queryParams\": {\n     #foreach($param in $input.params().querystring.keySet())\n     \"$param\": \"$util.escapeJavaScript($input.params().querystring.get($param))\" #if($foreach.hasNext),#end\n \n     #end\n   },\n   \"pathParams\": {\n     #foreach($param in $input.params().path.keySet())\n     \"$param\": \"$util.escapeJavaScript($input.params().path.get($param))\" #if($foreach.hasNext),#end\n \n     #end\n   }\n}"
        },
        "uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:111111111111:function:{{functionName}}/invocations",
        "credentials": "arn:aws:iam::111111111111:role/S3_DynamoDB",
        "passthroughBehavior": "when_no_match",
        "httpMethod": "{{functionMethod}}",
        "type": "aws"
      }
    },
    "x-amazon-apigateway-request-validator": "basic",
    "x-amazon-apigateway-request-validators": {
      "basic": {
        "validateRequestBody": true,
        "validateRequestParameters": true
      },
      "params-only": {
        "validateRequestBody": false,
        "validateRequestParameters": true
      }
    },
    "securityDefinitions": {
      "UserPool": {
        "type": "apiKey",
        "name": "Authorization",
        "in": "header",
        "x-amazon-apigateway-authtype": "cognito_user_pools",
        "x-amazon-apigateway-authorizer": {
          "providerARNs": [
            "arn:aws:cognito-idp:us-east-1:111111111111:userpool/us-east-1_XXXXXXXXX"
          ],
          "type": "cognito_user_pools"
        }
      }
    },
    "definitions": {
      "User": {
        "title": "User",
        "type": "object",
        "properties": {
          "UserName": {
            "type": "string"
          },
          "PassWord": {
            "type": "string",
            "minLength": 8
          }
        },
        "required": [
          "UserName",
          "PassWord"
        ]
      },
      "Empty": {
        "type": "object"
      }
    },
    "paths": {
      ".+": {
        "options": {
          "summary": "CORS support",
          "description": "Enable CORS by returning correct headers",
          "consumes": ["application/json"],
          "produces": ["application/json"],
          "tags": ["CORS"],
          "x-amazon-apigateway-integration": {
            "type": "mock",
            "requestTemplates": {
              "application/json": "{\n \"statusCode\" : 200\n}\n"
            },
            "responses": {
              "default": {
                "statusCode": "200",
                "responseParameters": {
                  "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization'",
                  "method.response.header.Access-Control-Allow-Methods": "'GET, PUT, POST, DELETE'",
                  "method.response.header.Access-Control-Allow-Origin": "'*'"
                },
                "responseTemplates": {
                  "application/json": "{}"
                }
              }
            }
          },
          "responses": {
            "200": {
              "description": "Default response for CORS method",
              "headers": {
                "Access-Control-Allow-Headers": {
                  "type": "string"
                },
                "Access-Control-Allow-Methods": {
                  "type": "string"
                },
                "Access-Control-Allow-Origin": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}

function.json

{
  "description": "get Property By PropertyId",
  "summary": "GetProperty",
  "x-api-gateway": {
    "method": "get",
    "path": "/Properties/{PropertyCode}",
    "security": [{
      "UserPool": []
    }],
    "parameters": [{
      "name": "Authorization",
      "in": "header",
      "description": "Authorization",
      "required": true,
      "type": "string"
    }]
  }
}

method and paths are required