-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
477 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,6 @@ coverage | |
|
||
# OSX | ||
.DS_Store | ||
|
||
# Python | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
packages/serverless-offline-dynamodb-streams-integration/handler.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import json | ||
|
||
def handler(event, context): | ||
print(event) | ||
return |
103 changes: 103 additions & 0 deletions
103
packages/serverless-offline-dynamodb-streams-integration/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
packages/serverless-offline-dynamodb-streams-integration/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "serverless-offline-dynamodb-streams-integration", | ||
"private": true, | ||
"scripts": { | ||
"start": "sls offline", | ||
"pretest": "docker-compose stop dynamodb && docker-compose rm -f dynamodb && docker-compose run dynamodb-create", | ||
"test": "node ./test.js" | ||
}, | ||
"dependencies": { | ||
"aws-sdk": "^2.444.0", | ||
"figures": "^3.0.0", | ||
"lodash": "^4.17.11", | ||
"serverless": "^1.41.1", | ||
"serverless-offline": "^4.9.4", | ||
"serverless-offline-dynamodb-streams": "1.5.1", | ||
"signal-exit": "^3.0.2" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
packages/serverless-offline-dynamodb-streams-integration/test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* eslint-disable unicorn/no-process-exit */ | ||
const {Writable} = require('stream'); | ||
const {spawn} = require('child_process'); | ||
const onExit = require('signal-exit'); | ||
const {DynamoDB} = require('aws-sdk'); | ||
|
||
const client = new DynamoDB({ | ||
region: 'eu-west-1', | ||
accessKeyId: 'local', | ||
secretAccessKey: 'local', | ||
endpoint: 'http://localhost:8000' | ||
}); | ||
|
||
const putItems = () => { | ||
return Promise.all([ | ||
client | ||
.putItem({ | ||
Item: {id: {S: 'MyFirstId'}}, | ||
TableName: 'MyFirstTable' | ||
}) | ||
.promise(), | ||
client | ||
.putItem({ | ||
Item: {id: {S: 'MySecondId'}}, | ||
TableName: 'MySecondTable' | ||
}) | ||
.promise(), | ||
client | ||
.putItem({ | ||
Item: {id: {S: 'MyThirdId'}}, | ||
TableName: 'MyThirdTable' | ||
}) | ||
.promise(), | ||
client | ||
.putItem({ | ||
Item: {id: {S: 'MyFourthId'}}, | ||
TableName: 'MyFourthTable' | ||
}) | ||
.promise() | ||
]); | ||
}; | ||
|
||
const serverless = spawn('sls', ['offline'], { | ||
stdio: ['pipe', 'pipe', 'pipe'], | ||
cwd: __dirname | ||
}); | ||
|
||
serverless.stdout.pipe( | ||
new Writable({ | ||
write(chunk, enc, cb) { | ||
const output = chunk.toString(); | ||
|
||
if (/Offline listening on/.test(output)) { | ||
putItems(); | ||
} | ||
|
||
this.count = (this.count || 0) + (output.match(/\[✔\]/g) || []).length; | ||
if (this.count === 4) serverless.kill(); | ||
cb(); | ||
} | ||
}) | ||
); | ||
|
||
serverless.stdout.on('data', data => { | ||
console.log(data.toString()); | ||
}); | ||
|
||
serverless.stderr.on('data', data => { | ||
console.error(data.toString()); | ||
process.exit(1); | ||
}); | ||
|
||
serverless.on('close', code => { | ||
process.exit(code); | ||
}); | ||
|
||
onExit((code, signal) => { | ||
if (signal) serverless.kill(signal); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
packages/serverless-offline-dynamodb-streams/example/package.json
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
packages/serverless-offline-dynamodb-streams/example/test.sh
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.