Reputation: 3714
How to promisify function what is Express middleware
(for example authenticate(arg1, arg2)(req, res, next)
)?
I tried promisify method from util
and also from es6-promisify
but none of those work. I am getting error:
TypeError: authenticate(...) is not a function
when I do:
const authenticate = promisify(passport.authenticate);
(passport.authenticate
) is the middleware.
My actual problem is:
I am using passport-jwt
module for passport
and I want to reuse passport.authenticate
middleware as normal isLoggedIn
function. I do not want to make same function to check JWT when there is this function. Also I do not want to promisify this middleware manually because I will be doing it in many places and its code repetition.
Upvotes: 2
Views: 441