Socket
Socket
Sign inDemoInstall

nano

Package Overview
Dependencies
Maintainers
2
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nano - npm Package Compare versions

Comparing version 3.3.3 to 3.3.4

35

nano.js

@@ -126,2 +126,4 @@ /* minimal couch in node

// add db to path if it was specified
// encode uri component is how its specified by couchdb to encode db name
if(opts.db) {

@@ -131,2 +133,3 @@ req.uri = u.resolve(req.uri, encodeURIComponent(opts.db));

// make sure we add our headers to the request
if (opts.headers) {

@@ -138,2 +141,3 @@ for (var k in opts.headers) {

// if there is a path append it to the path
if(opts.path) {

@@ -146,2 +150,3 @@ req.uri += "/" + opts.path;

try {
// docs get encoded with encode uri component too
req.uri += "/" + encodeURIComponent(opts.doc);

@@ -158,6 +163,7 @@ }

else {
// design document
// design document has no encoding
req.uri += "/" + opts.doc;
}
// add attachment if one was specified
if(opts.att) {

@@ -168,2 +174,3 @@ req.uri += "/" + opts.att;

// prevent bugs where people set encoding when piping
if(opts.encoding !== undefined && callback) {

@@ -175,2 +182,3 @@ req.encoding = opts.encoding;

// override content type
if(opts.content_type) {

@@ -181,2 +189,3 @@ req.headers["content-type"] = opts.content_type;

// cookie auth
if(cfg.cookie) {

@@ -210,2 +219,3 @@ req.headers["X-CouchDB-WWW-Authenticate"] = "Cookie";

// add our query string params
try {

@@ -248,2 +258,3 @@ req.uri += "?" + qs.stringify(params);

// if its a form make sure content type is set apropriately
if(opts.form) {

@@ -255,2 +266,3 @@ req.headers['content-type'] =

// log our request
log(req);

@@ -1009,14 +1021,25 @@

// nano('http://couch.nodejitsu.com/db1')
// nano({url: 'http://couch.nodejitsu.com/path', db: 'db1'})
// should return a database
// nano('http://couch.nodejitsu.com')
// should return a nano object
if(path.pathname && path_array.length > 0) {
if (path.pathname && path_array.length > 0) {
auth = path.auth ? path.auth + '@' : '';
port = path.port ? ':' + path.port : '';
db = path_array[0];
cfg.url = u.format(
{protocol:path.protocol,host: auth + path.hostname + port});
db = cfg.db ? cfg.db : path_array[0];
var format = {
protocol: path.protocol,
host: auth + path.hostname + port
};
if (cfg.db)
format.pathname = path.pathname + '/';
cfg.url = u.format(format);
return document_module(db);
}
else { return public_functions; }
else
return public_functions;

@@ -1023,0 +1046,0 @@ };

9

package.json

@@ -5,3 +5,3 @@ { "name" : "nano"

, "repository" : "git://github.com/dscape/nano"
, "version" : "3.3.3"
, "version" : "3.3.4"
, "author" : "Nuno Job <nunojobpinto@gmail.com> (http://nunojob.com)"

@@ -30,2 +30,5 @@ , "contributors" :

, "Paul Iannazzo <somethingitalian@gmail.com> (http://pppaul.me)"
, "Sebastian Tiedtke <sebastiantiedtke@gmail.com>"
, "Gregory T. Corrigan (https://github.com/corrigang)"
, "Etienne Folio (https://github.com/Ornthalas)"
]

@@ -35,3 +38,3 @@ , "keywords" :

, "dependencies" :
{ "request" : "2.9.x"
{ "request" : "2.12.x"
, "follow" : "0.8.x"

@@ -42,3 +45,3 @@ , "errs" : "0.2.x"

{ "async" : "0.1.x"
, "specify" : "0.6.x"
, "specify" : "1.1.x"
, "nock" : "0.13.x"

@@ -45,0 +48,0 @@ }

@@ -112,3 +112,3 @@ # nano

{ "url" : "http://localhost:5984/foo"
, "request_options" : { "proxy" : "http://someproxy" }
, "request_defaults" : { "proxy" : "http://someproxy" }
, "log" : function (id, args) {

@@ -119,10 +119,31 @@ console.log(id, args);

```
please check [request] for more information on the defaults. they support features like cookie jar, proxies, ssl, etc.
Please check [request] for more information on the defaults. They support features like cookie jar, proxies, ssl, etc.
### pool size
### pool size and open sockets
a very important configuration parameter if you have a high traffic website and are using nano is setting up the `pool.size`. by default the node.js http agent (client) has a certain size of active connections that can run simultaneously, while others are kept in a queue.
a very important configuration parameter if you have a high traffic website and are using nano is setting up the `pool.size`. by default, the node.js http global agent (client) has a certain size of active connections that can run simultaneously, while others are kept in a queue. pooling can be disabled by setting the `agent` property in `request_defaults` to false, or adjust the global pool size using:
you can increase the size using `request_options` if this is problematic, and refer to the [request] documentation and examples for further clarification
``` js
http.globalAgent.maxSockets = 20;
```
you can also increase the size in your calling context using `request_defaults` if this is problematic. refer to the [request] documentation and examples for further clarification.
here's an example explicitly using the keep alive agent (installed using `npm install agentkeepalive`), especially useful to limit your open sockets when doing high-volume access to couchdb on localhost:
``` js
var agentkeepalive = require('agentkeepalive');
var myagent = new agentkeepalive({
maxSockets: 50
, maxKeepAliveRequests: 0
, maxKeepAliveTime: 30000
});
var db = require('nano')(
{ "url" : "http://localhost:5984/foo"
, "request_defaults" : { "agent" : myagent }
});
```
## database functions

@@ -368,3 +389,3 @@

[couchdb doc](http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API).
additional query string `params` can be specified, `include_doc` is always set
additional query string `params` can be specified, `include_docs` is always set
to `true`.

@@ -444,3 +465,4 @@

calls a view of the specified design with optional query string additions
`params`.
`params`. if you're looking to filter the view results by key(s) pass an array of keys, e.g
`{ keys: ['key1', 'key2', 'key_n'] }`, as `params`.

@@ -457,9 +479,9 @@ ``` js

### db.show(designname, showname, docId, [params], [callback])
### db.show(designname, showname, doc_id, [params], [callback])
calls a show function of the specified design for the document specified by docId with
calls a show function of the specified design for the document specified by doc_id with
optional query string additions `params`.
``` js
alice.show('characters', 'formatDoc', '3621898430' function(err, doc) {
alice.show('characters', 'format_doc', '3621898430' function(err, doc) {
if (!err) {

@@ -508,3 +530,3 @@ console.log(doc);

callback(null, "It worked");
callback(null, "it worked");
});

@@ -532,3 +554,3 @@ ```

callback(null, "It worked");
callback(null, "it worked");
});

@@ -643,3 +665,3 @@ ```

http://www.apache.org/licenses/license-2.0
http://www.apache.org/licenses/LICENSE-2.0.html

@@ -646,0 +668,0 @@ unless required by applicable law or agreed to in writing, software

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc