3.0.0 • Published 4 months ago

@studio/gateway v3.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

Studio Gateway

A custom Swagger server and compiler with AWS Lambda and mock integration, for local API Gateway testing.

Features

  • Request parameters, header & query mappings
  • Request body models
  • Request-/Response Velocity templates and JSON Path queries
  • Response mappings with regular expressions
  • Response headers
  • AWS Lambda integration
  • AWS Mock integration
  • Swagger $ref to external files - compiles to single AWS compatible file

Usage

Assuming a swagger.json file in the current directory:

const Gateway = require('@studio/gateway');
const Lambda = require('@studio/lambda');

const lambda = Lambda.create();
const gateway = Gateway.create();
gateway.on('lambda', lambda.invoke);
gateway.listen(1337);

API

  • gateway = Gateway.create([options]): Returns a new gateway server for the given options.
    • swagger_file: The swagger file to read. Defaults to swagger.json.
    • swagger_env: The dotenv config to read.
    • stage: The stage name to use. Defaults to "local".
    • stageVariables: The stage variables to use. Default to an empty object.
  • gateway.listen(port[, callback]): Bind the server to the given port.

Events

  • lambda(name, event, context, callback): When a Lambda integration should be invoked. See @studio/lambda for a custom Lambda execution environment.

Swagger command

This module ships with a swagger command to compile a swagger.json file with references to other files into a single AWS compatible file.

Use in npm scripts like this:

{
  "scripts": {
    "swagger:prod": "swagger -o target/swagger-prod.json"
  }
}

The swagger optionally loads the dotenv module and replaces environment ${variables}.

These options are supported:

  • -f, --file: Sets the name of the swagger file. Defaults to swagger.json.
  • -e, --env: Sets the path to a dotenv config file.
  • -o, --outfile: Defines the output file to write to. If not specified, the result is printed to standard out.

Note that all environment variables can be used. When using npm scripts as shown above, you can also do things like ${npm_package_version}.

3.0.0

4 months ago

2.5.4

4 months ago

2.5.3

4 months ago

2.5.2

5 months ago

2.5.1

5 months ago

2.5.0

1 year ago

2.4.7

3 years ago

2.4.6

3 years ago

2.4.5

3 years ago

2.4.4

3 years ago

2.4.3

3 years ago

2.4.2

3 years ago

2.4.1

3 years ago

2.4.0

3 years ago

2.3.4

4 years ago

2.3.3

4 years ago

2.3.2

4 years ago

2.3.1

5 years ago

2.3.0

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.8.0

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.1

7 years ago

1.6.0

7 years ago

1.5.0

7 years ago

1.4.2

7 years ago

1.4.1

7 years ago

1.4.0

8 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago