dominictarr/npmd-cache — pull request #1 by novemberborn (2014-05-07 21:09:17+00:00)
Title: Support custom URL resolvers

I'm experimenting with using GitHub as a package registry, rather than running an NPM proxy, see . This can be achieved in npmd without too much trouble, provided URL resolution is customizable. It relates to .

This PR allows for decoration of the `get` method, when called if the to-be-resolved range is a URL. Combined with an option to forcibly set the `from` field of package objects this allows github-registry to rewrite something like `git://github.com/example/foo#^1.0.0` to `git://github.com/example/foo#v1.2.3`.

To support private repositories a mapping from cache keys to tarball URLs can be configured (and modified on the fly by the custom resolver). This allows github-registry to get a signed, temporary URL from the GitHub API and make `npmd-cache` use *that* URL to download and cache the tarball.

I suspect may be a better place to discuss these changes, so let me know if you want me to open an issue there.

Generally speaking I can see how you may want to avoid the config hooks as proposed in this PR, but regardless I think it makes for a neat little solution.