JWT - Why we don't need to store tokens in database?

I discussed a question with many people and the question was - Do you store the JWT tokens in the database?

First Answer:   Yes, we do store. Whenever we got an API call we get the token from the header and match it with the tokens that we have stored in DB.

Second Answer: No, we don't store tokens in a database we simply get them verified by JWT itself. We get the token from the header and pass it JWT verify method like jwt.verify(token, secret).

What I feel is that it is not required to store the tokens in the database. Because if you will be storing tokens in the database then you'll be setting some TTL(expiry time) there and on every request you will be verifying the token with user requested token and every time you'll update the TTL. ...  Read More

Share This:


How to use Typescript with Node.js | Building a Node.js App with TypeScript

If you are using Javascript to build your application it's fine if that is a small application but once your application becomes big, it's really hard to manage the code quality.

To write the manageable and typed Javascript we started using Typescript. Typescript is just the superset of Javascript which is strictly typed.

The issue with Typescript is, it can't simply run on the browser or V8 engine. We need to transpile the Typescript to Javascript. Here in this article, we are going to use TSC to transpile the Typescript to Javascript. ...  Read More

Share This: