from flask_limiter import Limiter
from flask_limiter.util import get_remote_address

def setup_limiter(app):

    # Rate limiter setup
    limiter = Limiter(
      key_func=get_remote_address,
      app=app,
      storage_uri=app.config['REDIS_URL'],
      default_limits=app.config['RATE_LIMITS']
    )

    return limiter
