Serverless Router plugin to handle http, streaming and other events at AWS λ
npm install @everestate/serverless-router-aws> Serverless Router plugin to handle http, streaming and other events at AWS λ
```
npm install @everestate/serverless-router @everestate/serverless-router-aws --save
#### DynamoDB
Steaming events from AWS DynamoDB.
`javascriptNew Foobar record inserted "${ctx.newItem}"
const FOOBAR_TABLE_STREAM_ARN = 'arn:aws:dynamodb:us-west-2:111122223333:table/FooTable/stream/2015-05-11T21:21:33.291';
router.dynamodb
.insert(FOOBAR_TABLE_STREAM_ARN, (ctx, _event) =>
console.log());`
ctx - routing context, it's content dependent on event type
event - API gateway event, same as dispatch receives
DynamoDB adapter implements insert, modify and remove methods.
See the documentation for more details: docs/DynamoDB.md
#### HTTP
HTTP Events from AWS API Gateway.
`javascriptget user by id "${ctx.id}"
router.http
.get('/users/:id', (ctx, event) =>
console.log())create new user with attributes "${event.body}"
.post('/users', (ctx, event) =>
console.log());`
ctx - routing context, object which contains path parameters (regexp tokens)
event - API gateway event, same as dispatch receives
HTTP adapter implements get, post, patch, put, delete and all methods.
See the documentation for more details: docs/HTTP.md
#### SQS
Steaming events from AWS SQS.
`javascriptNew nessage received"${ctx.messageAttribtues}"
const FOOBAR_QUEUE_STREAM_ARN = 'arn:aws:sqs:us-west-2:594035263019:FOOBARQUEUE';
router.sqs
.messgage(FOOBAR_TABLE_STREAM_ARN, (ctx, _event) =>
console.log());`
ctx - routing context, it contains the event payload
event - message gateway event, same as dispatch receives
SQS adapter implements message` method.
See the documentation for more details: docs/SQS.md