Skip to content

Commit 0e1d8c9

Browse files
author
cgohlke
committed
update README
1 parent ba78a65 commit 0e1d8c9

File tree

1 file changed

+39
-10
lines changed

1 file changed

+39
-10
lines changed

README.md

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,52 @@
33
[![npm version](https://badge.fury.io/js/aws-lambda-router.svg)](https://badge.fury.io/js/aws-lambda-router)
44
[![dependencies](https://david-dm.org/spring-media/aws-lambda-router.svg)](https://www.npmjs.com/package/aws-lambda-router)
55

6-
## aws-lambda-router
6+
# aws-lambda-router
77

8-
A small library providing routing for AWS ApiGateway Proxy Integrations and SNS...
8+
A small library for [AWS Lambda](https://aws.amazon.com/lambda/details) providing routing for [API Gateway](https://aws.amazon.com/api-gateway) [Proxy Integrations](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-set-up-simple-proxy.html) and [SNS](https://aws.amazon.com/sns).
99

10-
## Install
10+
## Features
11+
12+
* Easy Handling of [ANY method](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-settings-method-request.html#setup-method-add-http-method) in API Gateways
13+
* Simplifies writing lambda handlers (in nodejs)
14+
* Lambda Proxy Resource support for AWS API Gateway
15+
* Enable CORS for the requests
16+
17+
## Installation
18+
Install via npm.
1119

1220
```
1321
$ npm install aws-lambda-router
1422
```
1523

24+
## Getting Started
25+
26+
This is an simple using of `aws-lambda-router` in connection with ANY method and the API Gateway proxy Intergration. The following code will response with a message when executed using the AWS API Gateway with a `GET` request of URL path `<base-url-of-gateway/gateway-mapping/article/123`.
27+
28+
```js
29+
const router = require('aws-lambda-router');
30+
31+
// handler for an api gateway event
32+
exports.handler = router.handler(
33+
{
34+
// for handling an http-call from an AWS Apigateway proxyIntegration we provide the following config:
35+
proxyIntegration: {
36+
routes: [
37+
{
38+
// request-path-pattern with a path variable:
39+
path: '/article/:id',
40+
method: 'GET',
41+
// we can use the path param 'id' in the action call:
42+
action: (request, context) => {
43+
return "You called me with: " + request.paths.id;
44+
}
45+
}
46+
]
47+
}
48+
}
49+
50+
```
51+
1652
## Usage
1753
1854
```js
@@ -38,13 +74,6 @@ exports.handler = router.handler(
3874
// provide a function to be called with the propriate data
3975
action: (request, context) => doAnything(request.body)
4076
},
41-
{
42-
// request-path-pattern with a path variable:
43-
path: '/article/:id',
44-
method: 'GET',
45-
// we can use the path param 'id' in the action call:
46-
action: (request, context) => getSomething(request.paths.id)
47-
},
4877
{
4978
path: '/:id',
5079
method: 'DELETE',

0 commit comments

Comments
 (0)