Skip to content

Instantly share code, notes, and snippets.

@ryanramage
Last active December 14, 2015 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanramage/5041181 to your computer and use it in GitHub Desktop.
Save ryanramage/5041181 to your computer and use it in GitHub Desktop.
Couch URLs

Couch URLs

A small node module to help deal with an arbitraty url pointing to couchdb.

Why?

The goal of this library is to take one couchdb url, and provide as much information as possible about the couchdb that url is pointing to. It uses with the node 'url' module, and possibly some url probing to determine useful couchdb endpoints. Some information might take time to determine, so those methods will have a callback. Once called though, information will be cached so second and subsequent access will be fast.

Examples (why this library would be needed)

https://admin:pass@me.iriscouch.com/_couch/cool

This is an example of a couch with a vhost on, secure_rewrites=false, and a rewrite to the root couch api as _couch. Cool in this case would be a db


{
  couch_root: 'https://me.iriscouch.com/_couch',
  db_name: 'cool'
  username: 'admin'
  password: 'pass'
  roles: '_admin',
}

API


var couch_url = new CouchURLs('https://user:pass@mine.iriscouch.com/_db');
couch_url.parse(function(err, details){});


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment