Socket
Socket
Sign inDemoInstall

api-gateway-localdev

Package Overview
Dependencies
4
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    api-gateway-localdev

simulate AWS API Gateway for dev in your local


Version published
Maintainers
1
Created

Readme

Source

api-gateway-localdev

simulate AWS API Gateway for dev in your local

Installation

npm install api-gateway-localdev

Usage

app.js:

var express = require('express');
var apiGatewayLocal = require('api-gateway-localdev');

var app = apiGatewayLocal(express(), [
  {
    lambda: require("./lambda").handler,
    method: "GET",
    path: "/users/{username}",
    responses: {
        "200": {
          "responseTemplates": {},
          "responseModels": {}
        },
        "404": {
          "selectionPattern": ".*404.*",
          "responseTemplates": {},
          "responseModels": {}
        }
    }
    requestTemplates: {
      "application/json": '{"username": "$input.params(\'username\')"}'
    },
  }
]);

app.listen(8000);

lambda.js:

exports.handler = function (event, context) {
  context.done(null, findUser(event.username));
}

function findUser(username) {
  // ...
}

$ node ./app.js

API

var apiGatewayLocal = require('api-gateway-localdev')

apiGatewayLocal(app, routes)

  • Arguments
    • app - instance of express
    • routes - Array<map>
      • lambda - Function
      • method - String
      • path - String
      • statusCode - Number
      • responses - map<String, map>
        • 'status code' e.g. "200"
          • selectionPattern - String
          • responseTemplates - map<String, String|Buffer>
          • responseModels - map<String, String|Buffer>
      • requestTemplates - map<String, String|Buffer>
  • Return value
    • app

FAQs

Last updated on 28 May 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc