Permalink
Browse files

[dist] 1.3.2

minor api change to add support to pass path as a string with no options
  • Loading branch information...
1 parent 0ad8b89 commit 0000c1ed578d4180baa57a2a21361dd28a798d6d @dscape dscape committed Feb 17, 2012
Showing with 14 additions and 4 deletions.
  1. +5 −3 nano.js
  2. +1 −1 package.json
  3. +8 −0 tests/shared/cfg.js
View
@@ -67,7 +67,8 @@ module.exports = exports = nano = function database_module(cfg) {
* @error {request:socket} problem connecting to couchdb
* @error {couch:*} an error proxied from couchdb
*
- * @param {opts:object} request options; e.g. {db: "test", method: "GET"}
+ * @param {opts:object|string} request options;
+ * e.g. {db: "test", method: "GET"}
* {opts.db:string} database name
* {opts.method:string:optional} http method, defaults to "GET"
* {opts.path:string:optional} a full path, override `doc` and `att`
@@ -79,21 +80,22 @@ module.exports = exports = nano = function database_module(cfg) {
* @param {callback:function:optional} function to call back
*/
function relax(opts,callback) {
+ if(typeof opts === 'string') { opts = {path: opts}; }
var log = logging();
var headers = { "content-type": "application/json"
, "accept" : "application/json"
}
, req = { method : (opts.method || "GET")
, headers: headers
- , uri : cfg.url + "/" + opts.db }
+ , uri : cfg.url }
, params = opts.params
, status_code
, parsed
, rh
;
if (opts.jar) { req.jar = opts.jar; }
-
+ if(opts.db) { req.uri += "/" + opts.db; }
if(opts.path) { req.uri += "/" + opts.path; }
else if(opts.doc) {
if(!/^_design/.test(opts.doc)) {
View
@@ -2,7 +2,7 @@
, "description" : "minimalistic couchdb driver for node.js"
, "homepage" : "http://github.com/dscape/nano"
, "repository" : "git://github.com/dscape/nano"
-, "version" : "1.3.1"
+, "version" : "1.3.2"
, "author" : "Nuno Job <nunojobpinto@gmail.com> (http://nunojob.com)"
, "contributors" :
[ "Thiago Arrais <thiago.arrais@gmail.com> (http://thiagoarrais.com)"
View
@@ -7,6 +7,8 @@ var ensure = require('ensure')
;
couch = nock(cfg.url)
+ .get('/')
+ .reply(200, '{"couchdb":"Welcome","version":"1.1.0"}', {})
.get('/acb')
.reply(404, "{\"error\":\"not_found\",\"reason\":\"no_db_file\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)',
date: 'Fri, 02 Dec 2011 02:53:14 GMT',
@@ -32,6 +34,12 @@ var ensure = require('ensure')
'content-length': '44',
'cache-control': 'must-revalidate' });
+tests.root = function (callback) { nano(cfg.url).dinosaur('', callback); };
+tests.root_ok = function (e,b) {
+ this.t.ok(b.version);
+ this.t.equal(b.version, "1.1.0");
+};
+
tests.url = function (callback) { callback(null,nano('http://someurl.com')); };
tests.url_ok = function (_,n) { this.t.equal(n.config.url, "http://someurl.com"); };

0 comments on commit 0000c1e

Please sign in to comment.