Creates a BaseEPClient.
When shared is provided the constructor reuses those pre-built resources
instead of allocating new ones; this is the mechanism used by the facade to
ensure all sub-clients share one cache and one rate-limiter.
Client configuration (used when shared is absent)
Optionalshared: EPSharedResourcesPre-built shared resources (passed by facade to sub-clients)
Protected ReadonlybaseEuropean Parliament API base URL.
Protected ReadonlycacheLRU cache for API responses.
Private ReadonlycacheShared cache hit/miss counters (shared via EPSharedResources when used as sub-client).
Protected ReadonlyenableEnable automatic retry on transient failures.
Protected ReadonlymaxMaximum allowed response body size in bytes.
Protected ReadonlymaxMaximum number of retry attempts.
Protected ReadonlyrateToken bucket rate limiter.
Protected ReadonlytimeoutRequest timeout in milliseconds.
PrivatebuildPrivateBuilds the full request URL from endpoint + optional params.
Optionalparams: Record<string, unknown>Clears all entries from the LRU cache.
PrivatefetchPrivatefetchProtectedgetProtectedExecutes a cached, rate-limited GET request to the EP API.
Expected response type (extends Record<string, unknown>)
API endpoint path (relative to baseURL)
Optionalparams: Record<string, unknown>Optional query parameters
Promise resolving to the typed API response
PrivategetPrivateGenerates a deterministic cache key.
API endpoint path
Optionalparams: Record<string, unknown>Optional query parameters
JSON string used as cache key
Returns cache statistics for monitoring and debugging.
{ size, maxSize, hitRate, hits, misses }
PrivatereadPrivateshouldPrivateReturns true when an error should trigger a retry.
Retries on:
Does NOT retry on 4xx client errors (except 429).
PrivatetoPrivate StaticresolvePrivateResolves all EPClientConfig options to their final values with defaults applied. Extracted to keep constructor complexity within limits.
Base class for European Parliament API sub-clients.
Holds the shared HTTP machinery: LRU cache, token-bucket rate limiter, timeout/abort controller, and retry logic. Sub-clients extend this class and call the protected
get()helper for all HTTP requests.BaseEPClient