Skip to content

Commit 305f4cf

Browse files
committed
remove comments
1 parent 0898302 commit 305f4cf

2 files changed

Lines changed: 1 addition & 24 deletions

File tree

apps/webapp/app/services/apiRateLimit.server.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,7 @@ export const apiRateLimiter = authorizationRateLimitMiddleware({
5050
}
5151

5252
// Additional API keys (`tr_*_sk_*`) share their environment's rate limit
53-
// bucket rather than each getting their own. Keying on the stable
54-
// environment id (not the secret key, which can rotate) keeps a single
55-
// bucket per environment no matter how many additional keys exist.
56-
// Root/legacy keys fall through to the default per-key (hashed header)
57-
// bucketing: they already map 1:1 to an environment.
58-
//
59-
// This reuses the already-authenticated environment above; the whole
60-
// override result is cached per key by the middleware's SWR cache, so no
61-
// separate lookup or Redis mapping is needed for the identifier.
53+
// bucket rather than each getting their own.
6254
const apiKey = authenticatedEnv.apiKey;
6355
const identifier =
6456
apiKey && isAdditionalApiKey(apiKey) ? authenticatedEnv.environment.id : undefined;

apps/webapp/app/services/authorizationRateLimitMiddleware.server.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,6 @@ export const RateLimiterConfig = z.discriminatedUnion("type", [
5252

5353
export type RateLimiterConfig = z.infer<typeof RateLimiterConfig>;
5454

55-
/**
56-
* Result of an override lookup for a given Authorization header.
57-
*
58-
* - `config`: the rate limiter configuration to apply (bucket size). When
59-
* absent, the default limiter is used.
60-
* - `identifier`: the value to key the rate limit bucket on. When absent, the
61-
* hashed Authorization header is used (the legacy per-key behavior). Supply a
62-
* stable value (e.g. an environment id) so multiple credentials that should
63-
* share a bucket collapse onto one. Never a secret: it lands in Redis keys.
64-
*/
6555
type RateLimitOverride = {
6656
config?: unknown;
6757
identifier?: string;
@@ -136,8 +126,6 @@ async function resolveRateLimit(
136126
return { config: defaultLimiter } satisfies ResolvedRateLimit;
137127
}
138128

139-
// The identifier (if any) is trusted through even when the config falls back
140-
// to the default: bucketing and bucket size are independent concerns.
141129
const identifier = override.identifier;
142130

143131
if (!override.config) {
@@ -309,9 +297,6 @@ export function authorizationRateLimitMiddleware({
309297
limiterConfigOverride
310298
);
311299

312-
// Bucket key: an override-supplied identifier (e.g. environment id, so all
313-
// additional API keys for an environment share one bucket) or, by default,
314-
// the hashed Authorization header (legacy per-key behavior).
315300
const rateLimitIdentifier = identifier ?? hashedAuthorizationValue;
316301

317302
const limiter = createLimiterFromConfig(limiterConfig);

0 commit comments

Comments
 (0)