Skip to content

ioredis support #22

@directormac

Description

@directormac

Just followed the read me and what was suggested by @MathurAditya724 .

and in reference to #10

Reproducible snippet

import Redis from 'ioredis';
import { env } from './env.util';
import { rateLimiter } from 'hono-rate-limiter';
import { generateId } from './crypto.util';

import { type Store } from 'hono-rate-limiter';
import { RedisStore } from 'rate-limit-redis';

const client = new Redis(env.REDIS_URL);

const limiter = rateLimiter({
	windowMs: 15 * 60 * 1000,
	limit: 100,
	// Change the header according to your proxy
	keyGenerator: (c) => c.req.header('X-Forwarded-for') + generateId(20),
	store: new RedisStore({
		sendCommand: (...args: string[]) => client.sendCommand(args)
	}) as unknown as Store // Adding the correct type
});

export { client, limiter };

Type error is
image

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions