Property 'rateLimit' does not exist on type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' #454
-
Am getting this error when I try to access the rateLimit property on the express request object. I want to use this to confirm that the limiting works. How do I make this work?
|
Beta Was this translation helpful? Give feedback.
Answered by
gamemaker1
Apr 30, 2024
Replies: 2 comments 4 replies
-
You could use the following: import type { AugmentedRequest } from 'express-rate-limit'
app.get('/ip', (req: AugmentedRequest, res: Response) => {
res.json({ ip: req.ip, limiter: req.rateLimit.remaining });
}); // this is for checking if server is behind a proxy/load balancer |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hello @gamemaker1 , thank you for your answer it worked. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The reset time is set by the middleware itself, you don't need to set it yourself.
You can access it in all requests handlers registered after the rate limiter using
req.rateLimit
.