Skip to content

Commit

Permalink
Tweak rate limit setup for multi rate limit routes (#1627)
Browse files Browse the repository at this point in the history
tweak rate limit setup for multi rate limit routes
  • Loading branch information
dholms authored Sep 18, 2023
1 parent a441da8 commit f69c1a7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/xrpc-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ export class Server {
? config.rateLimit
: [config.rateLimit]
this.routeRateLimiterFns[nsid] = []
for (const limit of limits) {
for (let i = 0; i < limits.length; i++) {
const limit = limits[i]
const { calcKey, calcPoints } = limit
if (isShared(limit)) {
const rateLimiter = this.sharedRateLimiters[limit.name]
Expand All @@ -420,7 +421,7 @@ export class Server {
} else {
const { durationMs, points } = limit
const rateLimiter = this.options.rateLimits?.creator({
keyPrefix: nsid,
keyPrefix: `nsid-${i}`,
durationMs,
points,
calcKey,
Expand Down

0 comments on commit f69c1a7

Please sign in to comment.