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

aws-api-gateway-cli

v2.0.2

Published

A simple CLI to test API Gateway endpoints with IAM authorization.

Downloads

7

Readme

AWS API Gateway Test CLI

A simple CLI to test API Gateway endpoints with IAM authorization. Uses the AWS SDK, AWS Cognito JS SDK, and the generic [API Gateway Client][apiGClient]. Using the login information given, this tool logs a user into the Cognito User Pool, gets the temporary IAM credentials, and makes the API request. It can be difficult to do these steps by hand without scripting them.

Installation

To install globally run the following:

$ npm install -g aws-api-gateway-cli

You can also use it locally using:

$ npx aws-api-gateway-cli

Usage

If you have it globally installed:

$ aws-api-gateway-cli \
  --username='johndoe' \
  --password='password' \
  --user-pool-id='us-east-1_Xxxxxxxx' \
  --app-client-id='29xxyyxxyxxxyyxxxyy' \
  --cognito-region='us-east-1' \
  --identity-pool-id='us-east-1:99xxyyx-9999-9999-xx0x-99xxxxxxxx' \
  --invoke-url='https://99xxxxxxx.execute-api.us-east-1.amazonaws.com' \
  --api-gateway-region='us-east-1' \
  --api-key='x3xaacea33DCDA3aqafae28aCdaeEWXX1ada3acx' \
  --path-template='/users' \
  --method='GET' \
  --params='{}' \
  --additional-params='{}' \
  --access-token-header='cognito-access-token' \
  --body='{}'

If you have it locally installed:

$ npx aws-api-gateway-cli --options

This command takes the following options:

  • username The username of the Cognito User Pool user.

  • password The password of the Cognito User Pool user.

  • user-pool-id The Cognito User Pool Id.

  • app-client-id The Cognito User Pool App Client Id.

  • cognito-region The Cognito User Pool region. Defaults to us-east-1.

  • identity-pool-id The Cognito Identity Pool Id.

  • invoke-url The API Gateway root endpoint.

  • api-gateway-region The API Gateway region. Defaults to us-east-1.

  • api-key The API key if required by the method. Defaults to none.

  • path-template The path template of the API.

  • method The API method. Defaults to GET.

  • params The API path params as a JSON string. Defaults to '{}'.

  • additional-params Any additional params (including the headers and querystring) as a JSON string. Defaults to '{}'.

  • access-token-header Header field on which to pass the access token.

  • body The request body as a JSON string. Defaults to '{}'. Alternatively, reference a file with a JSON string using --body='@mocks/create.json' where mocks/create.json is the file with the request body.

For additional documentation on the format for params and additional-params; refer to the generic [API Gateway Client][apiGClient] docs.

Examples

To pass in path parameters with your request.

$ npx aws-api-gateway-cli-test \
--username='[email protected]' \
--password='password' \
--user-pool-id='abc' \
--app-client-id='def' \
--cognito-region='us-east-1' \
--identity-pool-id='ghi' \
--invoke-url='https://123.execute-api.us-east-1.amazonaws.com/prod' \
--api-gateway-region='us-east-1' \
--path-template='/notes/{id}' \
--params='{"id":"456"}' \
--method='GET'

To pass in query parameters and headers with your request.

$ npx aws-api-gateway-cli-test \
--username='[email protected]' \
--password='password' \
--user-pool-id='abc' \
--app-client-id='def' \
--cognito-region='us-east-1' \
--identity-pool-id='ghi' \
--invoke-url='https://123.execute-api.us-east-1.amazonaws.com/prod' \
--api-gateway-region='us-east-1' \
--path-template='/notes' \
--additional-params='{"queryParams":{"param0":"abc"},"headers":{"param1":"123"}}' \
--method='GET'

Local Development

Clone the repo and initialize the project.

$ git clone https://github.com/tobkle/aws-api-gateway-cli.git
$ cd aws-api-gateway-cli
$ npm install

Test the command using node index.js.

To install the apig-test command, run the following:

$ npm link