Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/goldcaddy77/serverless-elasticsearch-client
🚀 Elasticsearch client for AWS that plays nicely with serverless-offline and signed requests
https://github.com/goldcaddy77/serverless-elasticsearch-client
aws aws-elasticsearch elasticsearch elasticsearch-client serverless serverless-offline signed-requests
Last synced: about 2 months ago
JSON representation
🚀 Elasticsearch client for AWS that plays nicely with serverless-offline and signed requests
- Host: GitHub
- URL: https://github.com/goldcaddy77/serverless-elasticsearch-client
- Owner: goldcaddy77
- License: mit
- Created: 2017-02-25T06:25:36.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T20:39:28.000Z (about 2 years ago)
- Last Synced: 2024-10-11T12:48:16.264Z (3 months ago)
- Topics: aws, aws-elasticsearch, elasticsearch, elasticsearch-client, serverless, serverless-offline, signed-requests
- Language: JavaScript
- Homepage:
- Size: 348 KB
- Stars: 6
- Watchers: 3
- Forks: 3
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# serverless-elasticsearch-client
[![serverless](https://img.shields.io/badge/serverless-1.0-dda415.svg)](http://www.serverless.com)
[![npm version](https://img.shields.io/npm/v/serverless-elasticsearch-client.svg)](https://www.npmjs.org/package/serverless-elasticsearch-client)
[![CircleCI](https://circleci.com/gh/goldcaddy77/serverless-elasticsearch-client/tree/master.svg?style=shield)](https://circleci.com/gh/goldcaddy77/serverless-elasticsearch-client/tree/master)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](#badge)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)## AWS Elasticsearch Client
Wrapper around [elasticsearch-js](https://github.com/elastic/elasticsearch-js) client that plays nicely with AWS and serverless. Features include:
- Uses [http-aws-es](https://github.com/TheDeveloper/http-aws-es) to sign your requests so that they're valid in AWS
- Plays nicely with [serverless-offline](https://github.com/dherault/serverless-offline)'s `IS_OFFLINE` environment variable
- Uses sane default environment variables for AWS config## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [API](#api)
- [Contribute](#contribute)
- [License](#license)## Install
```bash
npm install --save serverless-elasticsearch-client
```## Usage
Use this as you would use the standard [elasticsearch-js](https://github.com/elastic/elasticsearch-js) client.
```javascript
const createEsClient = require('serverless-elasticsearch-client')
const client = createEsClient({ envPrefix: 'AWS_ES' })
```## 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-elasticsearch-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-elasticsearch-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