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

gateraid

v0.1.0

Published

RAML to API Gateway tool

Downloads

3

Readme

gateraid

Gateraid is a small toolchain for publishing and managing API Gateway interfaces as defined by RAML API definitions. The goal is simple generation of API Gateways using static configuration for easy maintainance and reproducibility of AWS infrastructure and to simplify the configuration format for easier human readability and creation.

We use the RAML spec currently (v0.8) as it is defined by the RAML spec.

Install

npm install gateraid -g

The -h

  Usage: gateraid [options] <NAME>


  Commands:

    create [options] <filename>  Create new API Gateway from a RAML file definition.
    rm [options]                 Destroy an API
    config [action] [args...]    Manage config settings

  Options:

    -h, --help               output usage information
    -V, --version            output the version number
    -p, --profile [profile]  Select AWS credential profile to use [default].

Example

Here's a very small API defining a session authorization endpoint:

#%RAML 0.8

title: Authentication API
version: v1
baseUri: https://api.example.com/v1/
mediaType: application/json
schemas:
  - SessionRequest: !include schemas/requests/session.json
  - Session: !include schemas/responses/session.json

/session:
  get:
    description:
      Retreives login session from _heyo_session_id
    headers:
      Accept-Language:
        description: The user's language.
        type: string
        required: true
        example: 'en-US'
    queryParameters:
      _heyo_session_id:
        description: Login session id.
        type: string
        required: true
    responses:
      200:
        body:
          application/json: {}
      404:
        body:
          application/json: {}

  post:
    description:
      User Login.
    body:
      application/x-www-form-urlencoded:
        formParameters:
          email:
            description: Email Address.
            type: string
          password:
            description: Password.
            type: string
      application/json:
        schema: SessionRequest
    responses:
      200:
        body:
          application/json:
            schema: Session
      401:
        body:
          application/json: {}

Optionally, Amazon requires additional information to build out an end-to-end integration with other AWS or external services, such as Lambda or acting as HTTP proxies. This secondary configuration specifies the AWS specific portions of the API. The currently supported integration types are:

  • Lambda
  • HTTP Proxy

An example config might look like the following:

env: .env
endpoints:
  /session:
    get:
      type: http-proxy
      url: https://example.com/newToken
      http-method: GET
      params:
        integration.request.header.Authorization: method.request.querystring.session_id
      requests:
        form: templates/session/request/get.mustache
      responses:
        default:
          status-code: 200
          templates:
            json: templates/session/response/get.mustache
    post:
      type: lambda
      lambda-name: my-login-lambda
      iam-role: ExecLambdaRole
      requests:
        form: templates/session/request/post.mustache
        json: templates/session/request/post.mustache
      responses:
        'Unauthorized: Invalid .*':
          status-code: 400
          templates:
            json: {}
        default:
          status-code: 200

You will note in the config, there is a .env file listed. This will provide any secrets that you want to interpolate into the response folders, such as API keys or secret tokens. It should look like pairs of KEY=VALUE, one per line (a convention for .env files generally).

The mustache files can be anything you want to have as part of the response. For example, if you have a .env file similar to:

clientId=xxx
clientSecret=yyy
secretToken=zzz

Your response file might look like the following:

{
  "client_id": "{{clientId}}",
  "client_secret": "{{clientSecret}}",
  "code": "$input.params('confirmationcode')",
  "token": "{{secretToken}}",
  "raw_string": "$input.path('$')"
}

Which when rendered as part of the request/response template in the API Gateway, will look like the following JSON:

{
  "client_id": "xxx",
  "client_secret": "yyy",
  "code": "$input.params('confirmationcode')",
  "token": "zzz",
  "raw_string": "$input.path('$')"
}

Dev Help

Build code: npm run build Run: ./bin/gateraid -h

Run tests: npm run test