API rate guard for limiting requests per time window.
// Limit to 5 requests per 2 secondsconst guard = new ApiRateGuard({ windowMs: 2000, maxRequests: 5 });await guard.guardFetch('/api/patients'); Copy
// Limit to 5 requests per 2 secondsconst guard = new ApiRateGuard({ windowMs: 2000, maxRequests: 5 });await guard.guardFetch('/api/patients');
Wrap a fetch call. If the guard blocks, it throws ApiRunawayBlockedError (or queues/drops according to strategy).
Optional
Generic guard for arbitrary async API calls (Axios, graphql-request, etc.) Usage: await apiGuard.guard('POST /api/items', () => axios.post(...));
Clear counters for testing or when navigating away.
API rate guard for limiting requests per time window.
Example