Skip to content

mlucool/superagent-elasticsearch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A superagent connection implementation for elasticsearch

Resources

License

Stars

Watchers

Forks

Packages

No packages published