Fluent Request Builder
Construct complex HTTP requests with an intuitive, chainable API. Immutable by design to prevent side effects in concurrent environments.
Zero-dependency. Fully typed. Battle-tested resilience patterns — built on top of the Native Fetch API.

import { HttpAdapter, RetryPolicies } from '@yildizpay/http-adapter';
const adapter = HttpAdapter.builder()
.withInterceptor(new AuthInterceptor(), new LoggingInterceptor())
.withRetryPolicy(RetryPolicies.exponential(3))
.withCircuitBreaker({ failureThreshold: 5, resetTimeoutMs: 30_000 })
.withCorrelationId()
.build();import { RequestBuilder, HttpMethod } from '@yildizpay/http-adapter';
const request = new RequestBuilder('https://api.payment.com')
.setEndpoint('/v1/charges')
.setMethod(HttpMethod.POST)
.setBody({ amount: 1000, currency: 'USD' })
.build();import {
TooManyRequestsException,
CircuitBreakerOpenException,
NetworkException,
} from '@yildizpay/http-adapter';
try {
const response = await adapter.send<ChargeResponse>(request);
console.log('Charge ID:', response.data.id);
} catch (error) {
if (error instanceof TooManyRequestsException) {
console.warn(`Rate limited. Retry after ${error.getRetryAfterMs()}ms`);
} else if (error instanceof CircuitBreakerOpenException) {
console.error('Payment service unavailable. Failing fast.');
} else if (error instanceof NetworkException) {
console.error('Network failure:', error.toJSON());
}
}import { MockHttpAdapter } from '@yildizpay/http-adapter/testing';
const adapter = new MockHttpAdapter();
adapter
.onEndpoint('/v1/charges')
.mockResolvedValue({ id: 'ch_123', status: 'succeeded' });
await chargeService.process(order);
adapter.assertCalledWith('/v1/charges', { method: HttpMethod.POST });
adapter.assertCalledTimes(1);Built around the real challenges of service-to-service communication in production Node.js applications — not just wrapping fetch.
| Raw Fetch | axios | @yildizpay/http-adapter | |
|---|---|---|---|
| Typed exception per HTTP status code | — | — | ✅ |
| Built-in Circuit Breaker | — | — | ✅ |
| Per-request retry/circuit override | — | — | ✅ |
| Response validation hooks | — | — | ✅ |
isRetryable() signal on errors | — | — | ✅ |
Structured toJSON() on all errors | — | — | ✅ |
| First-class testing utilities | — | — | ✅ |
| Zero production dependencies | ✅ | — | ✅ |
| Runs on Node.js Native Fetch | ✅ | — | ✅ |