Lets change the token logic that we had to use jwts
jsonwebtoken
library as a dependency - https://www.npmjs.com/package/jsonwebtokengenerateToken
functionJWT_SECRET
variable<aside> 💡
Notice we put the username
inside the token. The jwt
holds your state.
You no longer need to store the token
in the global users
variable
</aside>
/me
endpoint, use jwt.verify
to verify the token