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

ES6 Import Not Working

Tarekrahman5500 opened this issue · comments

import {expressjwt} from "express-jwt";

// create function that prevent un auth login to access the api

function authJwt() {
    const secret = process.env.SECRET_KEY;
    const api = process.env.API_URL;
    return expressjwt({
        secret,
        algorithms: ['HS256']

    }).unless({
        path: [
            'api/v1/users/login'
        ]
    })
}
module.exports = authJwt

when use

var { expressjwt: jwt } = require("express-jwt");
 return jwt({))

work fine but i need in es6
the code work fine when not use es6 import style
express-jwt": "^7.7.5
xpress": "^4.18.1
node-16.15
os-windows 11

What is the error you get?

Btw you don’t need @types/express-jwt anymore. Newer versions include the types