Skip to content
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

Issue when upgrading from 6.1 to 8.4 #336

Open
gzhhong opened this issue Nov 1, 2023 · 1 comment
Open

Issue when upgrading from 6.1 to 8.4 #336

gzhhong opened this issue Nov 1, 2023 · 1 comment

Comments

@gzhhong
Copy link

gzhhong commented Nov 1, 2023

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

@spearmootz
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants