ifixkart-backend/app/core/limiter.py

14 lines
457 B
Python

from slowapi import Limiter
from slowapi.util import get_remote_address
from app.core.config.Config import settings
# Global SlowAPI Limiter instance
limiter = Limiter(
key_func=get_remote_address,
default_limits=["120/minute"]
)
# A local swarm originates from one IP. Rate limits are a production protection,
# not part of the journey under test, so disable them only in simulation mode.
if settings.SIMULATION_MODE:
limiter.enabled = False