Skip to content

Commit

Permalink
feat(rate-limits): use redis to support rate-limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed Feb 19, 2024
1 parent c1f0966 commit d9bd0fb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@
)

# Rate limitations
limiter = Limiter(
limiter_args = dict(
key_func=get_remote_address,
default_limits=[get_config().RATE_LIMITS_DEFAULT],
storage_uri=get_config().RATE_LIMITS_REDIS,
)
if get_config().SESSION_REDIS_URI:
limiter_args["storage_uri"] = get_config().SESSION_REDIS_URI
limiter = Limiter(**limiter_args)
app.state.limiter = limiter
app.add_middleware(SlowAPIMiddleware)

Expand Down

0 comments on commit d9bd0fb

Please sign in to comment.