hughsk/npm-stats — pull request #3 by dsc (2014-10-09 07:18:50+00:00)
Title: Updates to new "slightly less stupid" NPM Download API

Ultimately, this patch swaps out nano for the Downloads API, as the registry has started reverse-proxying metrics from ElasticSearch[1].

...But of course I didn't realize that's what was up at first, so I sorta did a few other things while investigating.

- Added a `stats.defaults(obj)` method to get/set the global default configuration (as I thought the URLs had merely moved again, and there was no way to fix this so `proud` would use it as well).
- Fetches downloads from the new API using `request`, maintaining backwards compat with the old key names.
- Implements the rest of `stats().module(name).totalDownloads()` by adding an optional `reduce` phase to the event stream.
- All download-related methods now accept options for `since` and `until` to time-bound the query, as well as `detail` ...though it is currently unused (it switches the query from `range` to `point` aggregation mode).

I think that's it. Version still needs to be bumped. I don't mind housekeeping if you want to add me as a maintainer. https://www.npmjs.org/~dsc

[1] Re: https://github.com/npm/npm-www/commit/8098d49c7dd7b7d7560d4a832a0d893549334ca8?diff=split#diff-1ae516c24e8538cb91e3c2670eab27d3R1