TODO

  • Make cron service and add this function
    async function removeExpiredToken(): Promise<number> {
      try {
        const result = await Session.deleteMany({
          expire: { $lt: Math.floor(Date.now() / 1000) },
        }).exec();
    
        return result.deletedCount || 0;
      } catch {
        logger.debug('Token auto removal failed');
      }
      return 0;
    }
  • Error code handler
  • env var verifier
  • Dto class verifier : https://docs.nestjs.com/techniques/validation
  • Health Checks : https://docs.nestjs.com/recipes/terminus
  • CronJob : https://docs.nestjs.com/techniques/task-scheduling
  • Swagger
  • Session controller -> Token deletion on admin page
  • Testing
  • Refresh Token invalid/expired -> cookie auto removal
  • Access Token expired -> refresh token auto renewal
  • JWT forbidden error change
  • JWT Verify user level endpoint
  • Docker dev envrionment integration
  • Query sorting

REF

Token invalidation

https://medium.com/@byeduardoac/managing-jwt-token-expiration-bfb2bd6ea584

NestJS basics

https://wanago.io/2020/05/25/api-nestjs-authenticating-users-bcrypt-passport-jwt-cookies/