ncb000gt/node-elasticsearch — pull request #13 by brozeph (2013-06-28 14:54:10+00:00)
Title: V0.3.1

Hey fellas,

This is a pretty bit set of changes... I want to run this by you for code review and get your thoughts to ensure high quality.

#### Background

I started working on a new branch because there was some additional functionality that I was looking to use and I am quite fond of this library (because you have invited me into the fold to work on it with you)! I then had the hair-brained idea, "hey, I should make this thing work with all teh APIs exposed via Elasticsearch!".

#### Backwards Compatibility

You'll likely notice that this is a fairly impactful change... I preserved many of the code patterns from v0.2.x but literally every line has been touched. I tried, wherever possible, to preserve backwards compatibility for anyone just grabbing this lib off the shelf to run with it.

For the most basic use case (new up the lib and run a query), everything will work as before. You'll notice in `index.js` I remap `config.index` to `config._index` and in the core file, I alias `core.search` with `core.query`. There are a few other places in the code this is happening as well... but I documented those up in the actual code files for clarity.

One huge area of backwards incompatibility, though, is `es.indices`. In v0.2.x all operations where located under the `es.index`, but in v0.3.x, that is actually a method that adds a document to Elasticsearch (it's also aliased as `es.add`).

#### Continuous Integration

I added jshint to the npm test scripts as well as jscoverage and a link to coveralls.io so we get a cool code coverage badge:

Unit test coverage is at 100%... these truly are unit tests though. In `test/common.js` you can see where I mock the `req.delete`, `req.get`, `req.head`, `req.post` and `req.put`.

#### Documentation

I took a pass though the readme.md and documented it all up to represent the usage... it has been substantially changed. I apologize for the GFM reformat... it was a bit faster to type a series of `#` symbols to denote headers than carriage return and use dashes.

#### General Coding Notes

Yes... I have massive OCD. You'll notice every single method and every single unit test (and in most cases, every single variable) is alphabetized when it is declared. I apologize in advance for this. :-(

Throughout `core.js`, `indices.js` and `cluster.js` you'll notice a very similar pattern for each operation:

```
self.operation = function (options, someData, callback) {
// do the optional variable dance here...

// do the required parameter checks here

// construct the path here

// issue the http/https request last and return it to exit
};
```