-
-
Save zoutepopcorn/fce6537d11c9889ff2ab97e0886dfbe8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jwt = require('jsonwebtoken'); | |
const s = require('signale'); | |
const token = jwt.sign({ | |
user: 'johan' | |
}, 'aaaaa', { | |
expiresIn: '2s' | |
}); | |
s.time('expires'); | |
const getToken = () => { | |
jwt.verify(token, 'aaaaa', function(err, decoded) { | |
s.timeEnd('expires'); | |
if (err) { | |
s.error(err.message); | |
} else { | |
s.success(decoded) | |
console.log(decoded); | |
} | |
}); | |
} | |
setTimeout(() => { | |
getToken() | |
}, Math.random() * 1800); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment