title: How to reset number of attempts for user who succeeded in his request to log in with express-rate-limit
body: <p>I'm trying to implement a rate limiter for my site with <code>express-rate-limit</code> and I cannot seem to find how to reset the counter of attempts for user who made a successful request.
  My code:</p>
  <pre class="lang-ts prettyprint-override"><code>const loginLimiter = rateLimit({
      windowMs: 60 * 60 * 1000, 
      max: 4, 
      standardHeaders: true, 
      legacyHeaders: false,
      handler: function (req, res /*next*/) {
          return res.status(429).json({
              message: 'Too many failed login attempts, please try again later',
          });
      },
      skipSuccessfulRequests: true,
  });
  
  
  router.post(
              '/login',
              loginLimiter,
              async (
                  req: Request,
                  res: Response,
                  next: NextFunction,
              ): Promise&lt;void&gt; =&gt; {
              
              //(some code)
              
              }
             );
  
  </code></pre>
  <p>Ok nvm. I figured it out you just need to add:</p>
  <pre><code>router.post(
              '/login',
              loginLimiter,
              async (
                  req: Request,
                  res: Response,
                  next: NextFunction,
              ): Promise&lt;void&gt; =&gt; {
  
              //---(solution)---
              loginLimiter.resetKey(req.ip)
              //---(solution)---
              
              //(some code)
              
              }
             );
  
  </code></pre>
  <p>I'm not deleting this question for people who may have encountered a similar problem.</p>