oauthinaction / oauth-in-action-code

Source code for OAuth 2 in Action
https://www.manning.com/books/oauth-2-in-action
Other
713 stars 535 forks source link

"nosql": "^3.0.3" has a bug #26

Closed kanian closed 4 years ago

kanian commented 5 years ago

To anybody going through the exercises after node v10.0.0,

nosql v3.0.3, used in the code exercises, has a bug in FileReader.prototype.open in index.js line 2388. The callback in fs signature is no longer optional since v7.0.0 and throws an error since node v10.0.0 However, newer versions of nosql, have a different API than the one used in the exercises code. A quick fix, just to follow the exercises: in the node_modules/nosql/index.js, at line 2388, change fs.close(fd); to fs.close(fd, err=>{console.log(err)});

Cheers

amchavan commented 5 years ago

Thank you Kanian.

kanian commented 4 years ago

You are welcome @amchavan

BobJackson commented 4 years ago

if your node version is newer,for example v10.15.0, you can fix it like following:

  1. update nosql version,for example , "nosql": "^5.0.0";
  2. replace nosql.one() -> nosql.find().make(function(filter){});

This is my code: protectedResource.js

    nosql.find().make( function(filter) {
        filter.where('access_token', '=', inToken);
        filter.callback(function (err, token) {
            if (token) {
                console.log("We found a matching token: %s", token);
                req.access_token = token[0];
            } else {
                console.log('No matching token was found.');
            }
            next();
        });
    });
jricher commented 4 years ago

Should be fixed by #44 .