superagent-elasticsearch
v0.1.1
Published
A superagent connection implementation for elasticsearch
Downloads
5
Maintainers
Readme
superagent-elasticserach
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
.