Summary of changes:

- updated copyright
 - several tempalate changes for the docs
 - added a config for grunt-contrib-watch
 - updated nock commit number
 - fixed the coverage script
 - removed the export_docs script
 - added error message for legacy "es" users who don't have a version locked and have not upgraded
 - host will now add auth to urls created with `#makeUrl()`
 - Log class no longer looks for `config.loggers`
 - The log class now properly escapes single quotes in trace logs
 - Removed compiled yaml_tests.js from the repo
 - Yaml suite will only log error and warning messages unless the VERBOSE env var is set
 - createDefer is now a global setting, changed by modifying Transport.createDefer fubction
 - wrote tests for Content-Type checking
 - callbacks will now return the body and status of the request (if the request has completed) when an error occurs
 - Stdio logger now adds "Elasticsearch " to the front of log messages to distinguish it from other output to stdout.
This commit is contained in:
Spencer Alger
2013-12-15 14:08:29 -07:00
parent 0c8bd328fe
commit 37cd2f4f6c
20 changed files with 229 additions and 34803 deletions

View File

@ -5,6 +5,7 @@
* It will also instruct the client to use Angular's $http service for it's ajax requests
*/
var AngularConnector = require('./lib/connectors/angular');
var Transport = require('./lib/transport');
var Client = require('./lib/client');
process.angular_build = true;
@ -16,12 +17,14 @@ angular.module('elasticsearch.client', [])
AngularConnector.prototype.$http = $http;
AngularConnector.prototype.$q = $q;
// make the Transport return $q promisses instead
Transport.createDefer = function () {
return $q.defer();
};
var factory = function (config) {
config = config || {};
config.connectionClass = AngularConnector;
config.createDefer = function () {
return $q.defer();
};
return new Client(config);
};

View File

@ -1,9 +1,15 @@
var es = {
Client: require('./lib/client'),
ConnectionPool: require('./lib/connection_pool'),
Transport: require('./lib/transport'),
// In order to help people who were accidentally upgraded to this ES client,
// throw an error when they try to instanciate the exported function.
// previous "elasticsearch" module -> https://github.com/ncb000gt/node-es
function es() {
throw new Error('Looks like you are expecting the previous "elasticsearch" module. ' +
'It is now the "es" module. To create a client with this module use ' +
'`new es.Client(params)`.');
}
errors: require('./lib/errors')
};
es.Client = require('./lib/client');
es.ConnectionPool = require('./lib/connection_pool');
es.Transport = require('./lib/transport');
es.errors = require('./lib/errors');
module.exports = es;

View File

@ -36,4 +36,5 @@ AngularConnector.prototype.request = function (params, cb) {
// must be overwritten before this connection can be used
AngularConnector.prototype.$http = null;
// required in order to provide abort functionality
AngularConnector.prototype.$q = null;

View File

@ -128,7 +128,14 @@ Host.prototype.makeUrl = function (params) {
query = qs.stringify(this.query);
}
return this.protocol + '://' + this.host + port + path + (query ? '?' + query : '');
var auth = '';
if (params.auth) {
auth = params.auth + '@';
} else if (this.auth) {
auth = this.auth + '@';
}
return this.protocol + '://' + auth + this.host + port + path + (query ? '?' + query : '');
};
Host.prototype.toString = function () {

View File

@ -22,10 +22,6 @@ function Log(config) {
var i;
var outputs;
if (config.loggers) {
config.log = config.loggers;
}
if (config.log) {
if (_.isArrayOfStrings(config.log)) {
outputs = [{
@ -305,8 +301,7 @@ Log.prototype.trace = function (method, requestUrl, body, responseBody, response
function prettyJSON(body) {
try {
// TESTME
return JSON.stringify(JSON.parse(body), null, ' ').replace(/'/g, '\\\'');
return JSON.stringify(JSON.parse(body), null, ' ').replace(/'/g, '\\u0027');
} catch (e) {
return body || '';
}