-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove bluebird #58
remove bluebird #58
Conversation
I like this. Bluebird is a large import for simply promisifying a single function that can be done as simply as this PR does. I think i'd like it more if the import of jsonwebtoken and promisification is moved to another file |
@sc0ttyd added a verify.js |
Looks good, thanks! Just two very minor things. The import of |
@sc0ttyd Beware that removing Bluebird is a backwards incompatible change since you are returning the |
@sc0ttyd looks good. |
Koa v2 processes it's middleware stack internally through |
You are right on that. Good call. But what about potential modules that could be extending this middleware functionality by calling the exported function manually? I mean, like so: const jwt = require('koa-jwt')();
module.exports = function(opts) {
return jwt(opts)
.thenReturn(someObject) // Deliberately using Bluebird's API
.asCallback(done);
} I understand this scenario is less likely to occur in the wild, but not impossible. And we'll be breaking those.
Unsure, TBH. What are the implications of that? And, if we do it, wouldn't it be against the intention of this PR (removing a dependency on a Promise library)? |
We would be swapping one dependency for another, yes. But it would be one that is guaranteed to be present anyway since
Good example, I didn't consider that. With that in mind, I think you're right regarding the major version bump. |
After thinking about it a bit more and looking into it, the SemVer spec itself states as point 1:
Since our documentation and koa's documentation on the usage of middleware are as close as we come to having an explicit public API, we either consider that to be our public API or we aren't SemVer. With this in mind, usage of |
Although this PR shows as merged, the changes were not incorporated due to the ongoing discussion, and were reverted by a subsequent commit. Unfortunately merging PR #72 caused GitHub to mark #58 as merged and will not let me re-open that PR (sorry @scttcper!). Probably best if we continue to discuss on Issue #74 |
removes bluebird requirement and wraps the JWT verify function in a native promise.