adriantanasa / connect-cloudant-store

NodeJS express-session storage connector for IBM Cloudant
MIT License
14 stars 6 forks source link

destroy function is missing a return statement #16

Open lmeerma opened 4 years ago

lmeerma commented 4 years ago

Hi there,

the destroy function currently only returns when an error occurs since you're missing to return the callback function when the session was destroyed successfully.

CloudantStore.prototype.destroy = function(sid, fn) {
    debug('DESTROY session "%s"', sid);
    fn = fn || noop;
    // get _rev needed for delete
    // TODO check why db.head is not working
    self.db.get(self.prefix + sid).then(function(data) {
        // cleanup expired sessions
        self.db.destroy(self.prefix + sid, data._rev)
        .catch(function(err) {
            debug('DESTROY - DB error "%s" rev "%s" err "%s"', sid, data._rev,
            JSON.stringify(err));
            self.emit('error', err);
            return fn(err);
        });
    }).catch(function(err) {
        debug('DESTROY - DB GET failure "%s" err "%s"', sid, JSON.stringify(err));
        self.emit('error', err);
        return fn(err);
    });
};

After self.db.destroy(self.prefix + sid, data._rev) there should be a then method returning the callback function.