https://github.com/goldcaddy77/serverless-dynamo-client
🚀 Wrapper around the official dynamoDB client that plays well with serverless-offline
https://github.com/goldcaddy77/serverless-dynamo-client
aws aws-dynamodb dynamodb serverless serverless-offline
Last synced: about 1 month ago
JSON representation
🚀 Wrapper around the official dynamoDB client that plays well with serverless-offline
- Host: GitHub
- URL: https://github.com/goldcaddy77/serverless-dynamo-client
- Owner: goldcaddy77
- License: mit
- Created: 2017-03-02T03:04:42.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-31T19:26:30.000Z (about 9 years ago)
- Last Synced: 2025-08-09T15:51:39.171Z (11 months ago)
- Topics: aws, aws-dynamodb, dynamodb, serverless, serverless-offline
- Language: JavaScript
- Homepage:
- Size: 30.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# serverless-dynamo-client
[](http://www.serverless.com)
[](https://www.npmjs.org/package/serverless-dynamo-client)
[](https://standardjs.com)
## AWS DynamoDB client
This is a wrapper around the official AWS.DynamoDB SDK that:
- Plays nicely with [serverless-offline](https://github.com/dherault/serverless-offline) by providing sane defaults based on `IS_OFFLINE` environment variable.
- Looks for AWS region in configurable environment variable (details below)
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [API](#api)
- [Contribute](#contribute)
- [License](#license)
## Install
```bash
npm install --save serverless-dynamo-client
```
## Usage
```javascript
var dynamo = require('serverless-dynamo-client')
const client = dynamo.getClient({
envPrefix: 'AWS_DDB',
maxRetries: 3
})
const docClient = dynamo.getDocumentClient({
convertEmptyValues: true
})
```
## API
### Shared [options]
The following options are shared between the two methods below.
* `envPrefix` {string} if this is set, DDB will look for config in environment variables prefixed by `envPrefix`.
* `region` {string} if not set, DDB will look in `${envPrefix}_REGION`. If `envPrefix` is not set, it looks at
`AWS_REGION`. If still not found, when in `serverless-offline` mode, it will fall back to `localhost`
* `endpoint` {string} if in `serverless-offline` mode, this defaults to `http://localhost:8000`
* `sslEnabled` {boolean} defaults to `true`, if in `serverless-offline` mode, it is set to false
### getClient([options])
* `options` {Object - shared options above or [AWS.DynamoDB standard options](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#constructor-property)}
### Method: dynamo.getClient
Creates an `AWS.DynamoDB` with provided options.
```javascript
var dynamo = require('serverless-dynamo-client')
const docClient = dynamo.getClient({
envPrefix: 'AWS_DDB',
maxRetries: 3
})
```
### getDocumentClient([options])
* `options` {Object - shared options above or [AWS.DynamoDB.DocumentClient standard options](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#constructor-property)}
### Method: dynamo.getDocumentClient
Creates an `AWS.DynamoDB.DocumentClient` with provided options.
```javascript
var dynamo = require('serverless-dynamo-client')
const docClient = dynamo.getDocumentClient({
convertEmptyValues: true
})
```
## Contribute
PRs accepted. Note that code uses [standard](https://github.com/feross/standard) styling.
## License
MIT © Dan Caddigan