@everestate/serverless-router-aws
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -1,2 +0,2 @@ | ||
#### Route steaming events from AWS DynamoDB. | ||
#### Route streaming events from AWS DynamoDB. | ||
@@ -3,0 +3,0 @@ Supported methods |
const DynamoDB = require('./lib/DynamoDB'); | ||
const Http = require('./lib/Http'); | ||
const SQS = require('./lib/SQS'); | ||
const HTTP = require('./lib/HTTP'); | ||
module.exports = { | ||
DynamoDB, | ||
Http, | ||
HTTP, | ||
SQS, | ||
}; |
@@ -14,3 +14,4 @@ module.exports = { | ||
'lib/DynamoDB/__tests__/__fixtures__/', | ||
'lib/SQS/__tests__/__fixtures__/', | ||
], | ||
}; |
@@ -23,11 +23,11 @@ const BasePlugin = require('@everestate/serverless-router/lib/BasePlugin'); | ||
const record = event.Records[0]; | ||
return record.eventName === eventNameToMatch && record.eventSourceARN === eventSourceARNToMatch; | ||
if (record.eventName !== eventNameToMatch || record.eventSourceARN !== eventSourceARNToMatch) { | ||
return null; | ||
} | ||
return createLazyContext(record); | ||
}; | ||
} | ||
static ctx(event) { | ||
return createLazyContext(event.Records[0]); | ||
} | ||
} | ||
module.exports = DynamoDB; |
{ | ||
"name": "@everestate/serverless-router-aws", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "Serverless Router plugin to handle http, streaming and other events at AWS λ", | ||
@@ -12,2 +12,4 @@ "keywords": [ | ||
"dynamodb", | ||
"http", | ||
"sqs", | ||
"streaming" | ||
@@ -37,13 +39,13 @@ ], | ||
"dependencies": { | ||
"@everestate/serverless-router": ">=0.3.0", | ||
"@everestate/serverless-router": ">=0.4.0", | ||
"aws-sdk": ">=2.0.0 <3.0.0", | ||
"path-to-regexp": ">=2.0.0 <3.0.0" | ||
"path-to-regexp": ">=2.0.0 <4.0.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^5.11.0", | ||
"eslint": "^5.12.1", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-jest": "^22.1.2", | ||
"eslint-plugin-import": "^2.15.0", | ||
"eslint-plugin-jest": "^22.1.3", | ||
"jest": "^23.6.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# @everestate/serverless-router-aws | ||
# @everestate/serverless-router-aws [![npm version](https://badge.fury.io/js/%40everestate%2Fserverless-router-aws.svg)](https://www.npmjs.com/package/@everestate/serverless-router-aws) | ||
@@ -21,3 +21,3 @@ > [Serverless Router](https://github.com/everestate/serverless-router) plugin to handle http, streaming and other events at AWS λ | ||
.insert(FOOBAR_TABLE_STREAM_ARN, (ctx, _event) => | ||
console.log(`New Foobar record in inserted "${ctx.newItem}"`)); | ||
console.log(`New Foobar record inserted "${ctx.newItem}"`)); | ||
``` | ||
@@ -32,3 +32,3 @@ | ||
#### [Http](./docs/Http.md) | ||
#### [HTTP](./docs/HTTP.md) | ||
@@ -40,3 +40,3 @@ HTTP Events from AWS API Gateway. | ||
.get('/users/:id', (ctx, event) => | ||
console.log(`get user by id "${event.pathParameters.id}"`)) | ||
console.log(`get user by id "${ctx.id}"`)) | ||
.post('/users', (ctx, event) => | ||
@@ -46,11 +46,31 @@ console.log(`create new user with attributes "${event.body}"`)); | ||
**`ctx`** - routing context, currently it's always an empty object | ||
**`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](./docs/Http.md) | ||
HTTP adapter implements `get`, `post`, `patch`, `put`, `delete` and `all` methods. | ||
See the documentation for more details: [docs/HTTP.md](./docs/HTTP.md) | ||
#### [SQS](./docs/SQS.md) | ||
Steaming events from AWS SQS. | ||
```javascript | ||
const FOOBAR_QUEUE_STREAM_ARN = 'arn:aws:sqs:us-west-2:594035263019:FOOBARQUEUE'; | ||
router.sqs | ||
.messgage(FOOBAR_TABLE_STREAM_ARN, (ctx, _event) => | ||
console.log(`New nessage received"${ctx.messageAttribtues}"`)); | ||
``` | ||
**`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](./docs/SQS.md) | ||
## License | ||
[MIT](./LICENSE) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
192726
30
585
73
+ Addedpath-to-regexp@3.3.0(transitive)
- Removedpath-to-regexp@2.4.0(transitive)