Conversation
every time a jwt is to be decoded, check in the node cache instead of decoding it everytime using the verifyIdToken method
Make unnecessary callbacks async to give a response to the client asap. Use lean and select mongoose functions
|
|
| try { | ||
| console.time("firebase"); | ||
|
|
||
| let userToken = tokenCache.get(idToken); | ||
| if (userToken === undefined) { | ||
| const decodedToken = await firebaseApp.auth().verifyIdToken(idToken) | ||
| // eslint-disable-next-line prefer-destructuring | ||
| userToken={ uid: decodedToken.uid, mongoID: decodedToken.mongoID } | ||
| tokenCache.set(idToken, userToken,36000); | ||
| } |
There was a problem hiding this comment.
Scenario
at t=0, Firebase minted JWT for the user
at t=30 min, App sent that token to the server
This caches the JWT for 60 mins, whereas it should cache only for 30 mins
Ideally
Store the exp of the JWT when you cache and check it also
There was a problem hiding this comment.
Great Suggestion. Will do it soon! 🚀
|
Deployed to staging at http://staging.nitrkl.in/ |
|
|



This PR includes
Some Metrics