Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

claudia-api-builder

claudiajs19.1kMIT4.1.2

Simplify AWS ApiGateway handling

claudia, aws, lambda, apigateway, s3, api, microservices, serverless

readme

Claudia API Builder

npm npm npm Build Status Join the chat at https://gitter.im/claudiajs/claudia

Claudia API Builder makes it possible to use AWS API Gateway as if it were a lightweight JavaScript web server, so it helps developers get started easily and reduces the learning curve required to launch web APIs in AWS. Check out this video to see how to create and deploy an API in under 5 minutes.

Claudia.js Introduction Video

The API Builder helps you by:

  • setting up AWS API Gateway Web interfaces for Lambda projects easily, the way JavaScript developers expect out of the box
  • routing multiple AWS API Gateway end-points to a single Lambda function, so that you can develop and deploy an entire API simpler and avoid inconsistencies.
  • handling synchronous responses or asynchronous promises, so you can develop easier
  • configuring response content types and HTTP codes easily
  • enabling you to set-up post-install configuration steps, so that you can set up the deployments easier

The API builder is designed to work with Claudia, and add minimal overhead to client projects.

Simple example

var ApiBuilder = require('claudia-api-builder'),
    api = new ApiBuilder(),
    superb = require('superb');

module.exports = api;

api.get('/greet', function (request) {
    return request.queryString.name + ' is ' + superb.random();
});

For a more examples, see the Web API Example Projects

Getting started

  • Check out the Getting Started guide for a basic Hello-World style example
  • Check out the API Documentation for a detailed guide on handling requests, customising responses and configuring your API

Questions, suggestions?

Join the chat at https://gitter.im/claudiajs/claudia

License

MIT

changelog

Release history

4.1.0 15 June 2017

  • ApiResponse is now static, so it's easier to use in your own functions, thanks to Aaron J. Lang
  • bugfix for greedy path routing when the API_GW request type is used, thanks to Aaron J. Lang

4.0.0 9 April 2017

  • bumping version for sync with claudia

2.5.1, 7 June 2017

  • easier handling for Lambda environment and stage variables, using {mergeVars: true}

2.4.2, 3 May 2017

  • API builder will not explode, but provide a helpful error message when invalid or circular JSON structures passed as application/json requests or responses

2.4.0, 17 January 2017

  • support for API Gateway Binary content handling

2.3.0, 3 December 2016

  • expose CORS Max-Age in the config, so Claudia can set it even when default CORS settings are used on API Gateway

2.2.0, 28 November 2016

  • Allow ApiResponse to be returned from an interceptor, so it can send back a custom error code

2.1.0, 24 November 2016

  • enable max-age to be specified on CORS headers (thanks to Philipp Holly) \
  • limit magic location header only to actual 3xx redirects (301 and 302), allowing other codes such as 304 to be handled differently, fixes issue 20

2.0.2, 25. October 2016

  • bugfix for setting the Access-Control-Allow-Credentials header, thanks to StampStyle

2.0.1, 16. October 2016

  • bugfix for intercepting non-web requests, where 2.0 introduced backwards incompatibility wrapping even non-API Gateway requests into proxyRequest. The behaviour is now compatible with 1.x, where non-web requests are sent to the intercepting function unmodified.

2.0.0, 27. September 2016

  • support for API Gateway Lambda Proxy Integrations
  • support for routing via .ANY method
  • support for selecting request type (either CLAUDIA_API_BUILDER or AWS_PROXY)
  • support for dynamic response codes
  • completed CORS support (all HTTP method request handlers can now also limit CORS allowed origins, instead of just the OPTIONS one)
  • support for asynchronous CORS origin filters
  • stopping support for Node 0.10
  • (will only work with claudia 2.x)

1.6.0, 26 August 2016

  • support for custom authorizers

1.5.1, 4 August 2016

  • by default, API processing stops the node VM using the callbackWaitsForEmptyEventLoop Lambda context parameter. This is to prevent runaway node.js events caused by third party libs causing the Lambda VM to become stuck after a request completes. If you really want the VM execution to continue until the event loop empties, even after your API process is done, then set lambdaContext.callbackWaitsForEmptyEventLoop to true in your request handler.

1.5.0, 12 July 2016

  • support for intercepting and modifying requests

1.4.1, 1.4.0, 11 July 2016

  • shortcut for configuring stage variables during deployment
  • you can now provide a handler for unsupported event formats, and invoke the same Lambda from a source that's not API Gateway