Skip to content

Issue when upgrading from 6.1 to 8.4 #336

@gzhhong

Description

@gzhhong

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions