auth0 / express-jwt

connect/express middleware that validates a JsonWebToken (JWT) and set the req.user with the attributes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue when upgrading from 6.1 to 8.4

gzhhong opened this issue · comments

Hello,

Here is my code:


import expressJwt from 'express-jwt';
import User from "../models/user";

function jwt(){
    const secret = process.env.JWT_SECRET;
    return expressJwt({secret, algorithms: ['HS256'], isRevoked}).unless({
        path : [
            { url: '/', methods: ['GET'] },
        ]
   })


async function isRevoked(req, payload, done){
    const user = await User.findById(payload.sub);
    if (!user) {
        return done(null, true);
    }
    done();
}

export default jwt;

The code run without any error in version 6.1 of express-jwt, but failed with error after upgrade to 8.4.1

error message as below:

/Users/zhihong/workspace/iot-portal/iot-journey-api/dist/config/jwt.js:14
  return (0, _expressJwt.default)({
                                 ^

TypeError: (0 , _expressJwt.default) is not a function
    at jwt (/Users/zhihong/workspace/iot-portal/iot-journey-api/dist/config/jwt.js:14:34)
    at Server.create (/Users/zhihong/workspace/iot-portal/iot-journey-api/dist/Server.js:62:30)
    at Object.<anonymous> (/Users/zhihong/workspace/iot-portal/iot-journey-api/dist/index.js:33:29)
    at Module._compile (node:internal/modules/cjs/loader:1255:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1309:10)
    at Module.load (node:internal/modules/cjs/loader:1113:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47

How can I fix this issue?

Thanks a lot,

James