Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
// Settings
"passfail" : false, // Stop on first error.
"maxerr" : 500, // Maximum errors before stopping.
"multistr" : true,


// Predefined globals whom JSHint will ignore.
"node" : false,

"predef" : [ // Extra globals.
"__dirname",
"Buffer",
"event",
"exports",
"global",
"main",
"module",
"process",
"require",
"setTimeout",

"after",
"afterEach",
"afterAll",
"before",
"beforeEach",
"beforeAll",
"context",
"describe",
"it"
],

// Development.
"debug" : false, // Allow debugger statements e.g. browser breakpoints.
"devel" : true, // Allow development statements e.g. `console.log();`.


// EcmaScript 5.
"strict" : false, // Require `use strict` pragma in every file.
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').


"asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons).
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
"bitwise" : true, // Prohibit bitwise operators (&, |, ^, etc.).
"boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
"curly" : true, // Require {} for every new block or scope.
"eqeqeq" : false, // Require triple equals i.e. `===`.
"eqnull" : false, // Tolerate use of `== null`.
"evil" : false, // Tolerate use of `eval`.
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
"forin" : false, // Tolerate `for in` loops without `hasOwnProperty`.
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"latedef" : true, // Prohibit variable use before definition.
"loopfunc" : true, // Allow functions to be defined within loops.
//"maxparams" : 4,
//"maxdepth" : 5,
//"maxcomplexity" : 10,
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
"regexp" : false, // Prohibit `.` and `[^...]` in regular expressions.
"regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`.
"scripturl" : true, // Tolerate script-targeted URLs.
"shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
"undef" : true, // Require all non-global variables be declared before they are used.


"newcap" : false, // Require capitalization of all constructor functions e.g. `new F()`.
"noempty" : true, // Prohibit use of empty blocks.
"nonew" : false, // Prohibit use of constructors for side-effects.
"nomen" : false, // Prohibit use of initial or trailing underbars in names.
"onevar" : false, // Allow only one `var` statement per function.
"plusplus" : false, // Prohibit use of `++` & `--`.
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
"trailing" : false, // Prohibit trailing whitespaces. (only works if white is 'true')
"white" : false, // Check against strict whitespace and indentation rules.
"indent" : 4, // Enforce consistent indenting.
"unused" : true
}
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ test-cov: lib-cov
lib-cov:
@jscoverage lib $@

.PHONY: test test-cov
lint:
./node_modules/.bin/jshint ./lib --config .jshintrc && \
./node_modules/.bin/jshint ./test --config ./test/.jshintrc

.PHONY: test test-cov
118 changes: 61 additions & 57 deletions lib/elasticsearchclient/calls/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,118 +3,122 @@ ElasticSearchClient = require('../elasticSearchClient');

ElasticSearchClient.prototype.health = function(options, cb) {
//Pull the callback and set it false to not clobber id.
if(arguments.length > 0 && typeof arguments[arguments.length-1]=='function'){
cb=arguments[arguments.length-1];
arguments[arguments.length-1]=false;
if (arguments.length > 0 && typeof arguments[arguments.length - 1] == 'function') {
cb = arguments[arguments.length - 1];
arguments[arguments.length - 1] = false;
}

var path = '/_cluster/health'
var path = '/_cluster/health';
var qs = '';
if (options) {
qs = querystring.stringify(options)
qs = querystring.stringify(options);
}
if (qs.length > 0) {
path += "?" + qs;
}
return this.createCall({path: path, method: 'GET'}, this.clientOptions, cb);
}
};

ElasticSearchClient.prototype.state = function(options, cb) {
//Pull the callback and set it false to not clobber id.
if(arguments.length > 0 && typeof arguments[arguments.length-1]=='function'){
cb=arguments[arguments.length-1];
arguments[arguments.length-1]=false;
if (arguments.length > 0 && typeof arguments[arguments.length - 1] == 'function') {
cb = arguments[arguments.length - 1];
arguments[arguments.length - 1] = false;
}

var path = '/_cluster/state'
var path = '/_cluster/state';
var qs = '';
if (options) {
qs = querystring.stringify(options)
qs = querystring.stringify(options);
}
if (qs.length > 0) {
path += "?" + qs;
}
return this.createCall({path: path, method: 'GET'}, this.clientOptions, cb);
}
};


ElasticSearchClient.prototype.nodesInfo = function(nodes, options, cb) {
//Pull the callback and set it false to not clobber id.
if(arguments.length > 0 && typeof arguments[arguments.length-1]=='function'){
cb=arguments[arguments.length-1];
arguments[arguments.length-1]=false;
if (arguments.length > 0 && typeof arguments[arguments.length - 1] == 'function') {
cb = arguments[arguments.length - 1];
arguments[arguments.length - 1] = false;
}

var path = '/_cluster/nodes'
if(nodes instanceof Array){
for(n in nodes){
if(n==0)
path+='/'+nodes[n]
else
path+=','+nodes[n]
}
var path = '/_cluster/nodes';
if (Array.isArray(nodes)) {
for (var n in nodes) {
if (n === 0) {
path += '/' + nodes[n];
} else {
path += ',' + nodes[n];
}
}
}
var qs = '';
if (options) {
qs = querystring.stringify(options)
qs = querystring.stringify(options);
}
if (qs.length > 0) {
path += "?" + qs;
}
return this.createCall({path: path, method: 'GET'}, this.clientOptions, cb);
}
};

ElasticSearchClient.prototype.nodesStats = function(nodes, options, cb) {
//Pull the callback and set it false to not clobber id.
if(arguments.length > 0 && typeof arguments[arguments.length-1]=='function'){
cb=arguments[arguments.length-1];
arguments[arguments.length-1]=false;
if (arguments.length > 0 && typeof arguments[arguments.length - 1] == 'function') {
cb = arguments[arguments.length - 1];
arguments[arguments.length - 1] = false;
}

var path = '/_cluster/nodes'
if(nodes instanceof Array){
for(n in nodes){
if(n==0)
path+='/'+nodes[n]
else
path+=','+nodes[n]
}
}

path+='/stats'
var path = '/_cluster/nodes';
if (Array.isArray(nodes)) {
for (var n in nodes) {
if (n === 0) {
path += '/' + nodes[n];
} else {
path += ',' + nodes[n];
}
}
}

path += '/stats';
var qs = '';
if (options) {
qs = querystring.stringify(options)
qs = querystring.stringify(options);
}
if (qs.length > 0) {
path += "?" + qs;
}
return this.createCall({path: path, method: 'GET'}, this.clientOptions, cb);
}
};

ElasticSearchClient.prototype.nodesShutdown = function(nodes,options, cb) {
ElasticSearchClient.prototype.nodesShutdown = function(nodes, options, cb) {
//Pull the callback and set it false to not clobber id.
if(arguments.length > 0 && typeof arguments[arguments.length-1]=='function'){
cb=arguments[arguments.length-1];
arguments[arguments.length-1]=false;
if (arguments.length > 0 && typeof arguments[arguments.length - 1] == 'function') {
cb = arguments[arguments.length - 1];
arguments[arguments.length - 1] = false;
}

var path = '/_cluster/nodes';
if (Array.isArray(nodes)) {
for (var n in nodes) {
if (n === 0) {
path += '/' + nodes[n];
} else {
path += ',' + nodes[n];
}
}
}

var path = '/_cluster/nodes'
if(nodes instanceof Array){
for(n in nodes){
if(n==0)
path+='/'+nodes[n]
else
path+=','+nodes[n]
}
}
path+='/_shutdown'
path += '/_shutdown';
var qs = '';
if (options) {
qs = querystring.stringify(options)
qs = querystring.stringify(options);
}
if (qs.length > 0) {
path += "?" + qs;
}
return this.createCall({path: path, method: 'POST'}, this.clientOptions, cb);
}
};
Loading