Skip to content

Commit

Permalink
Tweak rate limit cfg (#1931)
Browse files Browse the repository at this point in the history
tweak rate limit cfg
  • Loading branch information
dholms authored Dec 5, 2023
1 parent e8473cb commit 90564ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions packages/bsky/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export interface ServerConfigValues {
triagePassword?: string
moderationPushUrl?: string
rateLimitsEnabled: boolean
rateLimitsBypassKey?: string
rateLimitsBypassIps?: string[]
rateLimitBypassKey?: string
rateLimitBypassIps?: string[]
}

export class ServerConfig {
Expand Down Expand Up @@ -119,9 +119,9 @@ export class ServerConfig {
process.env.MODERATION_PUSH_URL ||
undefined
const rateLimitsEnabled = process.env.RATE_LIMITS_ENABLED === 'true'
const rateLimitsBypassKey = process.env.RATE_LIMITS_BYPASS_KEY
const rateLimitsBypassIps = process.env.RATE_LIMITS_BYPASS_IPS
? process.env.RATE_LIMITS_BYPASS_IPS.split(',')
const rateLimitBypassKey = process.env.RATE_LIMIT_BYPASS_KEY
const rateLimitBypassIps = process.env.RATE_LIMIT_BYPASS_IPS
? process.env.RATE_LIMIT_BYPASS_IPS.split(',')
: undefined

return new ServerConfig({
Expand Down Expand Up @@ -154,8 +154,8 @@ export class ServerConfig {
triagePassword,
moderationPushUrl,
rateLimitsEnabled,
rateLimitsBypassKey,
rateLimitsBypassIps,
rateLimitBypassKey,
rateLimitBypassIps,
...stripUndefineds(overrides ?? {}),
})
}
Expand Down Expand Up @@ -289,12 +289,12 @@ export class ServerConfig {
return this.cfg.rateLimitsEnabled
}

get rateLimitsBypassKey() {
return this.cfg.rateLimitsBypassKey
get rateLimitBypassKey() {
return this.cfg.rateLimitBypassKey
}

get rateLimitsBypassIps() {
return this.cfg.rateLimitsBypassIps
get rateLimitBypassIps() {
return this.cfg.rateLimitBypassIps
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/bsky/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ export class BskyAppView {
if (config.rateLimitsEnabled) {
const rlCreator = (opts: RateLimiterOpts) =>
RateLimiter.redis(redis.driver, {
bypassSecret: config.rateLimitsBypassKey,
bypassIps: config.rateLimitsBypassIps,
bypassSecret: config.rateLimitBypassKey,
bypassIps: config.rateLimitBypassIps,
...opts,
})
xrpcOpts['rateLimits'] = {
Expand Down

0 comments on commit 90564ee

Please sign in to comment.