Open hpandelo opened 1 month ago
I think this sould resolve your issue -
app.use(rateLimiter({
windowMs: Deno.env.has('RATE_LIMIT_WINDOW_MS')
? +Deno.env.get('RATE_LIMIT_WINDOW_MS')!
: 60_000, // 1 minute
limit: Deno.env.has('RATE_LIMIT_MAX_REQUESTS')
? +Deno.env.get('RATE_LIMIT_MAX_REQUESTS')!
: 10,
standardHeaders: 'draft-6',
keyGenerator: (c) => c.req.header('x-forwarded-for') ?? '', // No types
}))
You need to provide the E
, P
and I
, generic types in the limiter.
I'm facing many issue with the types using Deno +
jsr:@hono/hono
+npm:hono-rate-limiter
The main one is the following:The code is pretty new, without so many personal things yet: It was originally inside the
RateLimitMiddleware
classIssue:
The other one is if I also try to type the
keyGenerator
it breaks too:keyGenerator: (c: Context) => c.req.header('x-forwarded-for') ?? '',
Aaaannnd... By typing the return of
rateLimiter
, it breaks like this one: