Aws Api Gateway Client

A client module of AWS API gateway both for Node.js and browsers
Alternatives To Aws Api Gateway Client
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Serverless Offline4,8561,30636817 days ago351September 23, 202279mitJavaScript
Emulate AWS λ and API Gateway locally when developing your Serverless project
Aws Serverless Workshops3,883
2 months ago1July 08, 202070apache-2.0JavaScript
Code and walkthrough labs to set up serverless applications for Wild Rydes workshops
Claudia3,70919329a year ago122March 17, 202214mitJavaScript
Deploy Node.js projects to AWS Lambda and API Gateway easily
Terraform Aws Vpc2,594
3 days ago27apache-2.0HCL
Terraform module which creates VPC resources on AWS 🇺🇦
Jets2,3738110 hours ago240August 08, 202236mitRuby
Ruby on Jets
Zappa2,33038969 days ago129November 11, 2021484mitPython
Serverless Python
Stack2,006
3 years ago49mitHCL
A set of Terraform modules for configuring production infrastructure with AWS
Event Gateway1,534
4 years ago60apache-2.0Go
React to any event with serverless functions across clouds
Fireprox1,339
2 months ago11gpl-3.0Python
AWS API Gateway management tool for creating on the fly HTTP pass-through proxies for unique IP rotation
Thingsboard Gateway1,286
11 hours ago76May 19, 202220apache-2.0Python
Open-source IoT Gateway - integrates devices connected to legacy and third-party systems with ThingsBoard IoT Platform using Modbus, CAN bus, BACnet, BLE, OPC-UA, MQTT, ODBC and REST protocols
Alternatives To Aws Api Gateway Client
Select To Compare


Alternative Project Comparisons
Readme

dependencies Status Build Status npm

Overview

A module for AWS API gateway client based on auto-generated JavaScript SDK. This module can be used not only for Node.js but for front-end. In addition, it generalizes original SDK's endpoint specific methods.

Reference: https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-generate-sdk.html

Prerequisites

For the JavaScript SDK to work your APIs need to support CORS. The Amazon API Gateway developer guide explains how to setup CORS for an endpoint.

Install

npm install aws-api-gateway-client

Use the SDK in your project

Require module

var apigClientFactory = require('aws-api-gateway-client').default;

Set invokeUrl to config and create a client. For authorization, additional information is required as explained below.

config = {invokeUrl:'https://xxxxx.execute-api.us-east-1.amazonaws.com'}
var apigClient = apigClientFactory.newClient(config);

Calls to an API take the form outlined below. Each API call returns a promise, that invokes either a success and failure callback

var pathParams = {
    //This is where path request params go.
    userId: '1234',
};
// Template syntax follows url-template https://www.npmjs.com/package/url-template
var pathTemplate = '/users/{userID}/profile'
var method = 'GET';
var additionalParams = {
    //If there are query parameters or headers that need to be sent with the request you can add them here
    headers: {
        param0: '',
        param1: ''
    },
    queryParams: {
        param0: '',
        param1: ''
    }
};
var body = {
    //This is where you define the body of the request
};

apigClient.invokeApi(pathParams, pathTemplate, method, additionalParams, body)
    .then(function(result){
        //This is where you would put a success callback
    }).catch( function(result){
        //This is where you would put an error callback
    });

Using AWS IAM for authorization

To initialize the SDK with AWS Credentials use the code below. Note, if you use credentials all requests to the API will be signed. This means you will have to set the appropriate CORS accept-* headers for each request.

var apigClient = apigClientFactory.newClient({
    invokeUrl:'https://xxxxx.execute-api.us-east-1.amazonaws.com', // REQUIRED

    region: 'eu-west-1',                                           // REQUIRED: The region where the API is deployed.

    accessKey: 'ACCESS_KEY',                                       // REQUIRED

    secretKey: 'SECRET_KEY',                                       // REQUIRED

    sessionToken: 'SESSION_TOKEN',                                 // OPTIONAL: If you are using temporary credentials
                                                                                you must include the session token.

    systemClockOffset: 0,                                          // OPTIONAL: An offset value in milliseconds to apply to signing time

    retries: 4,                                                    // OPTIONAL: Number of times to retry before failing. Uses axios-retry plugin.

    retryCondition: (err) => {                                     // OPTIONAL: Callback to further control if request should be retried.
      return err.response && err.response.status === 500;          //           Uses axios-retry plugin.
    },

    retryDelay: 100 || 'exponential' || (retryCount, error) => {   // OPTIONAL: Define delay (in ms) as a number, a callback, or
      return retryCount * 100                                      //           'exponential' to use the in-built exponential backoff
    },                                                             //           function. Uses axios-retry plugin. Default is no delay.

    shouldResetTimeout: false                                      // OPTIONAL: Defines if the timeout should be reset between retries. Unless
                                                                   //           `shouldResetTimeout` is set to `true`, the request timeout is
                                                                   //           interpreted as a global value, so it is not used for each retry,
                                                                   //           but for the whole request lifecycle.
});

Using API Keys

To use an API Key with the client SDK you can pass the key as a parameter to the Factory object. Note, if you use an apiKey it will be attached as the header 'x-api-key' to all requests to the API will be signed. This means you will have to set the appropriate CORS accept-* headers for each request.

var apigClient = apigClientFactory.newClient({
    invokeUrl:'https://xxxxx.execute-api.us-east-1.amazonaws.com', // REQUIRED
    apiKey: 'API_KEY', // REQUIRED
    region: 'eu-west-1' // REQUIRED
});
Popular Gateway Projects
Popular Amazon Web Services Projects
Popular Networking Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Javascript
Aws
Sdk
Gateway
Cors
Api Gateway