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-api-gateway

v0.4.0

Published

Create and deploy your Apex project on AWS API Gateway using Swagger configuration

Downloads

18

Readme

Apex API Gateway

apex-api-gateway helps you deploying your Apex project into API Gateway. This is an early version, only basic commands are available. If you need more advanced features, you can use AWS CLI.

npm version

This project was inspired by serverless-ci-example's Python deploy script.

Installation

npm install -g apex-api-gateway

Usage

Usage: apex-api-gateway <command> [options]

Commands:
  create <name> [description] [cloneFrom]  Create a new REST API on AWS API Gateway
  update                                   Update the REST API with the new Swagger definitions

Options:
  -c, --config  Apex project JSON file location
  --help        Display help [boolean]

To create an API and update Apex's configuration automatically, just simply do :

apex-api-gateway create 'My Awesome API'

Define swagger file in every function.json you have and main project.json (this should be done automatically later). You can check out the Apex API Gateway Boilerplate.

And to update API :

apex-api-gateway update

Writing your swagger definitions

project.json

After initiating your Apex project, you'll get a project.json containing everything Apex needs to run your lambas. We can then use it to define other definitions under a x-api-gateway key, and here's what you can define.

  • base_path
  • stage_name
  • rest-api-id: You can define this key yourself or let the create command do it for you

paths

You can use this key to match your functions's path and add default Swagger definition. For example, adding CORS to API Gateway can be done like this:

"paths": {
  ".+": { // this will match every path
    "options": { // adding options for preflight requests
      /*
        You can add CORS definitions for OPTIONS request here.
        Check out config example: http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html#enable-cors-for-resource-using-swagger-importer-tool
      */
    }
  },
  "/sweets(.+)": { // match a /sweets path and all the descendants
    "get": { /* ... */ },
    "put": { /* ... */ }
  }
}

Warning: ^ is prepended and $ is appended to the regex matching because I find it easier to match a plain path just writing it. This is questionable and if you disagree, you can open an issue to argue. :P

swagger-func-template

This template represents the default swagger definition for every function defined in your Apex project. The property's behavior is very similar to paths property and will likely be integrated into it in the future. The only difference is this definition is method agnostic.

Example:

"swagger-func-template": {
  "consumes": ["application/json"],
  "produces": ["application/json"],
  "responses": { /* ... */ },
  "x-amazon-apigateway-integration": { /* ... */ },
  "x-amazon-apigateway-auth" : { /* ... */ }
}

myFunction/function.json

This one is easier to define, just define your method in a x-api-gateway key like this:

"x-api-gateway": {
  "method": "post",
  "path": "/sweets",
  "parameters":[/* ... */]
  /* ... */
}

method and paths are required since it will be used as a key for the Swagger main file. The rest is only regular Swagger definition.