Socket
Socket
Sign inDemoInstall

ih-elastic-client

Package Overview
Dependencies
108
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.1-alpha to 2.0.2-alpha

73

lib/index.js

@@ -146,12 +146,8 @@ 'use strict';

function executeBasicGet(path, verbose) {
if (path.toLowerCase().includes('_search')) {
throw new Error('Basic Get cannot perform search.');
}
var profileMessage = 'ES Basic Get request.';
if (verbose) path = path + '?v';
if (path.toLowerCase().includes('_search')) {
throw new Error('Basic Get cannot perform search.');
}
if (verbose) path = path + '?v';
return httpGet(path)
.then(function(res) {
return parseElasticResponse(res, profileMessage);
});
return httpGet(path);
}

@@ -163,14 +159,14 @@

function scroll(results, res){
results = results.concat(res.hits.hits);
var curriedScroll = _.curry(scroll)(results);
if (results.length < res.hits.total) {
if (res.hits.hits.length === 0){
throw new Error('Scroll request timed out');
results = results.concat(res.hits.hits);
var curriedScroll = _.curry(scroll)(results);
if (results.length < res.hits.total) {
if (res.hits.hits.length === 0){
throw new Error('Scroll request timed out');
}
return pageScroll(parseScrollId(res))
.then(curriedScroll);
}
return pageScroll(parseScrollId(res))
.then(curriedScroll);
}
else {
return results;
}
else {
return results;
}

@@ -180,12 +176,12 @@ }

function httpGet(path) {
log.debug('Executing elastic get route: ...[%s]', path.substr(path.length-5, 5));
const options = buildHttpOptions('GET', path);
return rp(options);
log.debug('Executing elastic get route: ...[%s]', path.substr(path.length-5, 5));
const options = buildHttpOptions('GET', path);
return rp(options);
}
function httpPost(path, body, logMessage) {
logMessage = typeof logMessage !== 'undefined' ? logMessage : '';
log.debug('%s Executing elastic query route: [%s] body: %s', logMessage, path, body);
const options = buildHttpOptions('POST', path, body);
return rp(options);
logMessage = typeof logMessage !== 'undefined' ? logMessage : '';
log.debug('%s Executing elastic query route: [%s] body: %s', logMessage, path, body);
const options = buildHttpOptions('POST', path, body);
return rp(options);
}

@@ -197,4 +193,3 @@

method: method,
headers: headers,
transform: parseElasticResponse
headers: headers
};

@@ -220,21 +215,1 @@

function parseElasticResponse(response, profileMessage = 'Parse response') {
if (profileMessage) {
log.debug(profileMessage + ' READ');
}
let res;
try{
res = JSON.parse(response);
}catch (e){
log.debug(profileMessage + ' PARSE FAILED');
res = response;
}
if (profileMessage) {
log.debug(profileMessage + ' PARSE');
}
return res;
}
{
"name": "ih-elastic-client",
"version": "2.0.1-alpha",
"version": "2.0.2-alpha",
"description": "Influence Health basic nodejs elasticsearch client that hooks into ih-log and ih-config",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc