-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ioredis support #22
Comments
Hey @directormac, apologies that it took me some time to go through the issue, but upon close inspection, the problem isn't in You can check the reference here - |
so here is the new snippet according to that const limiter = rateLimiter({
windowMs: 15 * 60 * 1000,
limit: 100,
keyGenerator: (c) => c.req.header("X-Forwarded-for") + generateId(20),
store: new RedisStore({
sendCommand: (...args) => client.sendCommand(args) as Promise<RedisReply>,
}) as unknown as Store,
});
export { client, limiter }; Only wrong args being passed now would it be safe to assume that the args are commands? and just cast it like this
|
Yes, I also don't like these semi-typed functions, but this API is neither created nor maintained by me so can't change that. This usage is given here https://github.com/express-rate-limit/rate-limit-redis/tree/main?tab=readme-ov-file#examples, and honesty I went through the code base when I was building |
You should also put this in the examples incase someone needs it and close this issue. |
Yes, I am thinking the same |
Solutionconst limiter = rateLimiter({
windowMs: 15 * 60 * 1000,
limit: 100,
keyGenerator: (c) => c.req.header("X-Forwarded-for") + generateId(20),
store: new RedisStore({
sendCommand: (...args) => client.sendCommand(args as unknown as Command) as Promise<RedisReply>,
}) as unknown as Store,
});
export { client, limiter }; |
Object literal may only specify known properties, and 'sendCommand' does not exist in type 'Options'.ts(2353) something change? |
EDIT: I realized I was looking at the wrong library (@hono-rate-limiter/redis) when I was supposed to use rate-limit-redis instead. import { rateLimiter, type Store } from "hono-rate-limiter";
import { RedisStore, type RedisReply } from "rate-limit-redis";
const store = new RedisStore({
sendCommand: (...args) => {
return client.call(...args) as Promise<RedisReply>;
},
}) as unknown as Store; This still doesn't work as intended either though, because the rate limit seems to never expire ( |
I am not sure why you would be putting |
Can you share a reproduction or your code? |
Just followed the read me and what was suggested by @MathurAditya724 .
and in reference to #10
Reproducible snippet
Type error is
The text was updated successfully, but these errors were encountered: