"""
Rate limiting middleware using slowapi.

Provides protection against DOS attacks by limiting requests per IP address.
"""

from slowapi import Limiter
from slowapi.util import get_remote_address

# Create limiter instance
# Key function: use IP address to track requests
# Default limit: 100 requests per minute per IP
limiter = Limiter(
    key_func=get_remote_address,
    default_limits=["100/minute"],
    headers_enabled=False,  # Disable to avoid Response parameter requirement
)


def get_limiter():
    """Get the limiter instance for use in route decorators."""
    return limiter
