Easy and Fast jwt setup for your project.
This plugin makes use of fast-jwt with caching support out of the box.
MENU
npm i @xpresser/jwt
# OR
yarn add @xpresser/jwt
{
"npm://@xpresser/jwt": true
}
({
// ... Other Configs
"@xpresser/jwt": {
secretKey: "My Secret Key!",
signer: {
expiresIn: 3_600_000 // in 1 hour
},
verifier: {cache: true}
}
})
More signer
and verifier
configuration options can be found here
In your controller or anywhere in your project.
const {signJwt, verifyJwt} = require("@xpresser/jwt");
// Sign Data
const token = signJwt({user: 'john_doe'});
// Verify/Decode
verifyJwt(token)
// { user: "john_doe", iat: 1634151036, exp: 1634151046}