Implement a rate-limiting middleware for an API endpoint to prevent abuse while ensuring high availability.