Skip to content

Commit f8379b0

Browse files
authored
Merge pull request #55 from miltador/serverless-offline
Add compatibility with serverless-offline plugin
2 parents 5da9b02 + 5be7a54 commit f8379b0

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,20 @@ new AWS.DynamoDB({
182182
### Using with serverless-offline plugin
183183
When using this plugin with serverless-offline, it is difficult to use above syntax since the code should use DynamoDB Local for development, and use DynamoDB Online after provisioning in AWS. Therefore we suggest you to use [serverless-dynamodb-client](https://github.com/99xt/serverless-dynamodb-client) plugin in your code.
184184
185+
The `serverless dynamodb start` command can be triggered automatically when using `serverless-offline` plugin.
186+
Please note that you still need to install DynamoDB Local first.
187+
188+
Add both plugins to your `serverless.yml` file:
189+
```yaml
190+
plugins:
191+
- serverless-dynamodb-local
192+
- serverless-offline
193+
```
194+
195+
Make sure that `serverless-dynamodb-local` is above `serverless-offline` so it will be loaded earlier.
196+
197+
Now your local DynamoDB database will be automatically started before running `serverless offline`.
198+
185199
## Reference Project
186200
* [serverless-react-boilerplate](https://github.com/99xt/serverless-react-boilerplate)
187201

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class ServerlessDynamodbLocal {
113113
'dynamodb:remove:removeHandler': this.removeHandler.bind(this),
114114
'dynamodb:install:installHandler': this.installHandler.bind(this),
115115
'dynamodb:start:startHandler': this.startHandler.bind(this),
116+
'before:offline:start': this.startHandler.bind(this),
116117
};
117118
}
118119
createHandler() {

package.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,11 @@
3131
"scripts": {
3232
"test": "echo \"Warning: no test specified\" && exit 0"
3333
},
34-
"devDependencies": {
35-
"chai": "^3.2.0",
36-
"mocha": "^2.2.5"
37-
},
3834
"dependencies": {
39-
"aws-sdk": "^2.3.19",
40-
"bluebird": "^3.0.6",
41-
"dynamodb-localhost": "0.0.2",
42-
"dynamodb-migrations": "0.0.10",
43-
"lodash": "^4.13.1",
44-
"mkdirp": "^0.5.0",
45-
"tar": "^2.0.0"
35+
"aws-sdk": "^2.7.0",
36+
"bluebird": "^3.4.6",
37+
"dynamodb-localhost": "^0.0.4",
38+
"dynamodb-migrations": "^0.0.10",
39+
"lodash": "^4.17.0"
4640
}
4741
}

0 commit comments

Comments
 (0)