deitch / cansecurity

nodejs/expressjs authentication and security library
MIT License
150 stars 53 forks source link

Why not error first callbacks? #2

Closed stereosteve closed 8 years ago

stereosteve commented 12 years ago

Hello -

This package looks very nice for implementing simple token based authentication, and I am looking forward to trying it out. The readme was very helpful, but after the first read over the docs my question is why not use the standard error first callback style?

The getUser method has a signature like

getUser: function (username, successCallback, errCallback) {}

And in validatePassword, the callback takes arguments:

callback(userObject, errorObject, password)

Do you think it would be more consistent with node convention to use error first callbacks?

      getUser: function (username, callback) {}
      // and the callback takes
      callback(error, user)

And for validatePassword, the callback would look like:

  callback(error, user, password)

Any reason why you chose to not use this style of callbacks? Steve

deitch commented 12 years ago

Look forward to your feedback on using the module. Like most others, it was simply a "scratch your own itch" solution to a problem.

Why did we use the

function (username, success, err) {}

instead of

function(username, callback) {}

?

To be honest, I don't remember, it was just what we did. I am not wholly convinced it is worth breaking backwards compatibility for it, though.

deitch commented 11 years ago

Take a look at the 0.6.0 and up release, completely changes it. Is that what you mean?

deitch commented 8 years ago

Open several years, closing this out.