New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fermata-couchdb

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fermata-couchdb - npm Package Compare versions

Comparing version 0.10.7 to 0.10.8

32

fermata-couchdb.js

@@ -16,5 +16,10 @@ /* CouchDB (and friends) plugin for Fermata, with preliminary support for change events and default base URL.

(function () {
function autoBase(url) {
// TODO: better URL guessing (especially if window.location is available)
return url || "http://localhost:5984";
}
var plugin = function (transport, url) {
// TODO: better URL guessing (especially if window.location is available)
this.base = url || "http://localhost:5984";
this.base = autoBase(url);
return transport.using('statusCheck').using('autoConvert', "application/json");

@@ -133,5 +138,28 @@ };

// WORKAROUND: custom statusCheck to treat 202 responses as an error
// if Cloudant sends this, we can't be sure the write won't conflict
// see https://github.com/cloudant/bigcouch/issues/55#issuecomment-30186518
// and https://cloudant.com/for-developers/faq/data/
// and http://bigcouch.cloudant.com/api
// it's futile to attempt a unanimous quorum read to be sure (r=N is only advisory!!)
// so…assume the worst (e.g. conflicting or lost update) and treat these like a 500
plugin.bigcouch = function (transport, url) {
this.base = autoBase(url);
transport = transport.using('statusCheck').using('autoConvert', "application/json");
return function (req, cb) {
return transport(req, function (e, d, m) {
var status = m && m['X-Status-Code'];
if (!e && status === 202) {
e = Error("Troublesome status code from server: " + status);
e.status = status;
}
cb(e, d, m);
});
};
};
// some boilerplate to deal with browser vs. CommonJS
if (fermata) {
fermata.registerPlugin("couchdb", plugin);
fermata.registerPlugin("bigcouch", plugin.bigcouch);
} else {

@@ -138,0 +166,0 @@ module.exports = plugin;

2

package.json
{
"name": "fermata-couchdb",
"version": "0.10.7",
"version": "0.10.8",
"description": "CouchDB helpers for Fermata",

@@ -5,0 +5,0 @@ "main": "fermata-couchdb.js",

@@ -56,2 +56,16 @@ # fermata-couchdb

## Alternate Cloudant / BigCouch (/ CouchDB 2.0?) extended plugin
Cloudant's "BigCouch" version of CouchDB [does not actually enforce read quorums](https://github.com/cloudant/bigcouch/issues/55#issuecomment-30186518)! This means that if a quorum *write* request yields a 202 response, there is no way to ever know whether the write ended up conflicting or not. So my recommendation is to treat such writes as failed from the upstream code's perspective.
To facilitate this, this plugin offers a variant which, in the browser, is registered under the "bigcouch" name. To register under node.js you can follow this example, changing the variable names and/or registered name if you'd like:
var fermata = require('fermata'),
plugin = require('fermata-couchdb');
fermata.registerPlugin('bigcouch', plugin.bigcouch);
This alternate plugin is used exactly as the main plugin. The only difference is that a response with a 202 status code will cause an error callback rather than a successful callback.
## Changes watcher API

@@ -58,0 +72,0 @@

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