Config Builder
Generate production-ready configurations for Stable Infra modules. Configure all options visually and export TypeScript code ready to use.
** Required for config to work
* Required for this feature only
TypeScript Generics
Define TypeScript types for strong typing. Leave empty for any.
Type for request body data
Type for expected response data
Generate interface definitions above the function call
Interface name for request type
Interface name for response type
Request Data Required
Target server hostname without protocol (required)
/
URL path (leading / is automatic)
HTTP method
Request protocol
Port number
Request headers as JSON object
Request body for POST/PUT/PATCH
URL query parameters as JSON object
Individual request timeout
Retry Configuration
Total number of attempts
Delay growth pattern
Initial delay between retries
Maximum delay cap
Random delay variation
Continue all attempts even on success
Throw error if finalErrorAnalyzer returns false
Response Options
Include full response data instead of boolean
Pre-Execution Hook
Runs before main execution
Custom parameters for the hook
Apply hook's return config
Continue if hook fails
Analysis Hooks
Validate response and determine retry
Analyze final error after all attempts
Observability Hooks
Collect all error logs
Collect successful attempt data
Called on each error (requires Log All Errors)
Called on each successful attempt (requires Log All Successful Attempts)
Limit for serialized data in hooks
Hook Parameters
Params passed to responseAnalyzer hook
Params passed to handleSuccessfulAttemptData hook
Params passed to handleErrors hook
Params passed to finalErrorAnalyzer hook
Caching
Cache successful responses
Honor HTTP cache headers (default: enabled)
Cache entry time-to-live
Maximum cached entries
Comma-separated HTTP status codes
Custom cache key generation
Circuit Breaker
Percentage to trip breaker
Min requests before evaluation
Time before half-open state
Test requests in half-open
Success rate to close breaker
Track each attempt as request
Common Buffer
Initial buffer state object (required to enable buffer options)
Wrap in a StableBuffer instance for transactional state management
Timeout for buffer transactions (0 = no timeout)
Custom clone function for read(). Defaults to structuredClone or JSON cloning.
Optional function to log buffer transactions (receives StableBufferTransactionLog)
Define thresholds for buffer metrics validation
Metrics Guardrails
Note: This form shows only the most commonly used
min or max constraint for each metric. Each guardrail property actually accepts a full MetricGuardrail object.
Define thresholds for request execution metrics
Define thresholds for circuit breaker behavior
Define thresholds for cache performance
Trial Mode
Dry run without actual HTTP requests
Probability (0-1) that request fails in trial mode
Probability (0-1) that retry is not allowed
Transaction Logs
Called once before execution; logs are passed to all hooks
Pre-loaded logs (overridden by loadTransactionLogs)
Execution Context
Optional identifiers for workflow execution tracking
Generated Configuration
import { stableRequest } from '@emmvish/stable-infra';
const result = await stableRequest({
reqData: {
hostname: 'api.example.com',
// Add more options...
}
});
** Required for config to work
* Required for this feature only
TypeScript Generics
Define TypeScript types for strong typing. Leave empty for any.
Type for function arguments array
Type for function return value
Function Configuration Required
The function to execute (sync or async)
Array of arguments to pass to the function
Return actual result in data instead of boolean
Retry Configuration
Total number of attempts
Delay growth pattern
Initial delay between retries
Maximum delay cap
Random delay variation
Continue all attempts even on success
Throw error if finalErrorAnalyzer returns false
Timeout & Concurrency
Max time for entire execution (all attempts)
Semaphore-based concurrency limit
Pre-Execution Hook
Runs before main execution
Custom parameters for the hook
Apply hook's return config
Continue if hook fails
Analysis Hooks
Validate result and determine retry (return false to retry)
Analyze final error after all attempts (return true to suppress throw)
Observability Hooks
Collect all error logs
Collect successful attempt data
Called on each error (requires Log All Errors)
Called on each successful attempt (requires Log All Successful Attempts)
Limit for serialized data in hooks
Hook Parameters
Params passed to responseAnalyzer hook
Params passed to handleSuccessfulAttemptData hook
Params passed to handleErrors hook
Params passed to finalErrorAnalyzer hook
Caching
Cache successful function results
Cache entry time-to-live
Maximum cached entries
Custom cache key generation from args
Circuit Breaker
Percentage to trip breaker
Min requests before evaluation
Time before half-open state
Test requests in half-open
Success rate to close breaker
Track each attempt as request
Rate Limiting
Maximum requests in window
Sliding window duration
Common Buffer
Initial buffer state object (required to enable buffer options)
Wrap in a StableBuffer instance for transactional state management
Timeout for buffer transactions (0 = no timeout)
Custom clone function for read(). Defaults to structuredClone or JSON cloning.
Optional function to log buffer transactions (receives StableBufferTransactionLog)
Define thresholds for buffer metrics validation
Metrics Guardrails
Note: This form shows only the most commonly used
min or max constraint for each metric. Each guardrail property actually accepts a full MetricGuardrail object.
Define thresholds for function execution metrics
Define thresholds for circuit breaker behavior
Define thresholds for cache performance
Define thresholds for rate limiter behavior
Define thresholds for concurrency limiter behavior
Trial Mode
Dry run without actual function execution
Probability (0-1) that execution fails in trial mode
Probability (0-1) that retry is not allowed
Transaction Logs
Called once before execution; logs are passed to all hooks
Pre-loaded logs (overridden by loadTransactionLogs)
Execution Context
Optional identifiers for workflow execution tracking
Generated Configuration
import { stableFunction } from '@emmvish/stable-infra';
const result = await stableFunction({
fn: async () => { /* your function */ },
args: []
});
** Required for config to work
* Required for this feature only
Initial State
Starting state for the buffer. Defaults to empty object if not provided.
Transaction Configuration
Timeout for each transaction. 0 or empty disables timeouts.
Optional function to log transaction details (receives StableBufferTransactionLog)
Clone Function
Custom clone function for read(). Defaults to structuredClone or JSON cloning.
Metrics Guardrails
Note: This form shows only the most commonly used
min or max constraint for each metric. Each guardrail property actually accepts a full MetricGuardrail object.
Define thresholds for buffer performance validation
Key Methods
StableBuffer provides transactional state management.
buffer.read()
Returns a cloned snapshot of current state
buffer.getState()
Returns live reference (bypasses queue)
buffer.setState(newState)
Replaces internal state reference
buffer.transaction(fn)
Queued executor for safe mutations
buffer.update(mutator)
Convenience wrapper for void mutations
buffer.getMetrics()
Returns StableBufferMetrics with validation
Generated Configuration
import { StableBuffer } from '@emmvish/stable-infra';
const buffer = new StableBuffer();
// Basic usage
await buffer.transaction((state) => {
state.count = (state.count ?? 0) + 1;
});
console.log(buffer.read());
Premium Feature
For expert-level consultations on use of stable-infra's advanced modules, email your requirements to me, at: mvsn98@gmail.com.
You can also review the API References documentation for configuration options.