superagent-elasticsearch

0.1.1 • Public • Published

superagent-elasticserach

NPM version NPM DM Build Status Coverage Status Dependency Status

Elasticsearch javascript connection handler for Superagent

Why?

Superagent is widely used and it can easily be made to understand kerberos, in-house CAs and more. This is designed to allow you to pass in any superagent like-object as well as get a callback before the request is sent so you can take an action per request (e.g. set a Authenticate token).

Usage

Simple

const elasticsearch = require('elasticsearch');
const SuperagentConnector = require('superagent-elasticsearch');
 
client = new elasticsearch.Client({
    host,
    log: 'debug',
    connectionClass: SuperagentConnector,
});

Kerberos

const elasticsearch = require('elasticsearch');
const SuperagentConnector = require('superagent-elasticsearch');
 
const beforeEachRequest = (r) => async {
    const token = await getToken(r.url);
    r.set('Authorization', `Negotiate ${token}`);
    return;
};
client = new elasticsearch.Client({
    host,
    log: 'debug',
    connectionClass: SuperagentConnector,
    superagentConfig: {beforeEachRequest}
});

Recommended reading: https://www.npmjs.com/package/kerberos https://gist.github.com/dmansfield/c75817dcacc2393da0a7#file-http_client_spnego-js-L20

API

In the config of elasticsearch, pass a superagentConfig config object. Parameters documented in the constructor, as well as tested in ./tests.

License

Apache-2.0 License

Package Sidebar

Install

npm i superagent-elasticsearch

Weekly Downloads

1

Version

0.1.1

License

Apache-2.0

Unpacked Size

19.4 kB

Total Files

5

Last publish

Collaborators

  • mlucool