Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return utils.nodify(Promise.resolve().then(function () {
// add wrappers and make system db
if (!info.isOnlineAuthDB) {
wrappers.installWrapperMethods(args.db, writeWrappers);
systemDB.installSystemDBProtection(args.db);
// store validation doc
return args.db.put(designDoc);
}
}).catch(function (err) {
/* istanbul ignore if */
app.dbWrapper.registerWrapper(function (name, db, next) {
// db.info() should just return the non-uri encoded db name
wrappers.installWrapperMethods(db, {
info: function (orig) {
return orig().then(function (info) {
info.db_name = decodeURIComponent(info.db_name);
return info;
});
}
});
return next();
});
return origOn.apply(changes, [event, function (res) {
listener(modifyChanges(res));
}]);
}
return origOn.apply(changes, [event, listener]);
};
var origThen = changes.then;
changes.then = function (resolve, reject) {
return origThen.apply(changes, [function (res) {
resolve(modifyChanges(res));
}, reject]);
};
return changes;
};
wrappers.installWrapperMethods(db, handlers);
};
});
});
}]);
}
return origOn.apply(changes, [event, listener]);
};
var origThen = changes.then;
changes.then = function (resolve, reject) {
return origThen.apply(changes, [function (res) {
modifyChanges(res).then(resolve, reject);
}, reject]);
};
return changes;
};
wrappers.installWrapperMethods(db, handlers);
};
});
});
}]);
}
return origOn.apply(changes, [event, listener]);
};
var origThen = changes.then;
changes.then = function (resolve, reject) {
return origThen.apply(changes, [function (res) {
return modifyChanges(res).then(resolve, reject);
}, reject]);
};
return changes;
};
wrappers.installWrapperMethods(db, handlers);
};
app.dbWrapper.registerWrapper(function (name, db, next) {
//'fix' the PouchDB api (support opts arg everywhere)
function noop(orig) {
return orig();
}
var wrapperMethods = {};
['info', 'removeAttachment'].forEach(function (name) {
wrapperMethods[name] = noop;
});
wrappers.installWrapperMethods(db, wrapperMethods);
return next();
});