elasticsearch
Advanced tools
Comparing version 0.2.3 to 0.2.6
@@ -5,13 +5,16 @@ var utils = require('./utils'), | ||
function ElasticSearch(args) { | ||
var opts = args[0] || {}, | ||
cb = ((args.length>1)?args[1]:undefined); | ||
if (!(opts.index)) { | ||
throw new Error('Must specify an index for ES.'); | ||
} else if (!(opts.index instanceof Index)) { | ||
if (typeof(opts.index) == 'string') { | ||
this.index = new Index({name: opts.index}); | ||
} else { | ||
this.index = new Index(opts.index); | ||
} | ||
var opts = args[0] || {}; | ||
var cb = ((args.length>1)?args[1]:undefined); | ||
if (!(opts.index)) { | ||
throw new Error('Must specify an index for ES.'); | ||
} else if (!(opts.index instanceof Index)) { | ||
if (typeof(opts.index) == 'string') { | ||
this.index = new Index({name: opts.index}); | ||
} else { | ||
this.index = new Index(opts.index); | ||
} | ||
}; | ||
this.server_config = { | ||
@@ -27,3 +30,3 @@ auth : opts.auth || '', | ||
var self = this; | ||
this.index.create(function(err, res) { | ||
this.index.create(this.server_config, function(err, res) { | ||
if (cb) { | ||
@@ -30,0 +33,0 @@ cb(err, self); |
@@ -23,5 +23,2 @@ var http = require('http'); | ||
}); | ||
if (cb) { | ||
res.on('error', cb); | ||
} | ||
res.on('end', function() { | ||
@@ -59,7 +56,17 @@ var buf = new Buffer(length), | ||
var onError = function(err) { | ||
if (cb) { | ||
cb(err); | ||
} | ||
} | ||
var req; | ||
if (opts.secure) { | ||
req = https.request(opts, callback); | ||
req = https | ||
.request(opts, callback) | ||
.on('error', onError); | ||
} else { | ||
req = http.request(opts, callback); | ||
req = http | ||
.request(opts, callback) | ||
.on('error', onError); | ||
} | ||
@@ -66,0 +73,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"main": "index.js", | ||
"version": "0.2.3", | ||
"version": "0.2.6", | ||
"author": "Nick Campbell (http://github.com/ncb000gt)", | ||
@@ -8,0 +8,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22546
547