@yildizpay/http-adapter 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +17 -13
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,4 +1,8 @@
1
- # A HTTP Adapter for Node.js
1
+ # @yildizpay/http-adapter
2
+
3
+ ![Build Status](https://github.com/yildizpay/http-adapter/actions/workflows/ci.yml/badge.svg)
4
+ ![NPM Version](https://img.shields.io/npm/v/@yildizpay/http-adapter)
5
+ ![License](https://img.shields.io/npm/l/@yildizpay/http-adapter)
2
6
 
3
7
  A professional, robust, and highly configurable HTTP client adapter designed for enterprise-grade Node.js applications. It provides a fluent API, built-in resilience patterns, and a powerful interceptor system, all sitting on top of the reliable Axios library.
4
8
 
@@ -28,13 +32,13 @@ pnpm add @yildizpay/http-adapter
28
32
  Use the `RequestBuilder` to create requests cleanly and concisely.
29
33
 
30
34
  ```typescript
31
- import { RequestBuilder, HttpMethod } from "@yildizpay/http-adapter";
35
+ import { RequestBuilder, HttpMethod } from '@yildizpay/http-adapter';
32
36
 
33
- const request = new RequestBuilder("https://api.example.com")
34
- .setEndpoint("/users")
37
+ const request = new RequestBuilder('https://api.example.com')
38
+ .setEndpoint('/users')
35
39
  .setMethod(HttpMethod.POST)
36
- .addHeader("Authorization", "Bearer token")
37
- .setBody({ name: "John Doe", email: "john@example.com" })
40
+ .addHeader('Authorization', 'Bearer token')
41
+ .setBody({ name: 'John Doe', email: 'john@example.com' })
38
42
  .build();
39
43
  ```
40
44
 
@@ -43,13 +47,13 @@ const request = new RequestBuilder("https://api.example.com")
43
47
  Instantiate the `HttpAdapter` with optional interceptors and retry policies.
44
48
 
45
49
  ```typescript
46
- import { HttpAdapter, RetryPolicies } from "@yildizpay/http-adapter";
50
+ import { HttpAdapter, RetryPolicies } from '@yildizpay/http-adapter';
47
51
 
48
52
  const adapter = HttpAdapter.create(
49
53
  [
50
54
  /* interceptors */
51
55
  ],
52
- RetryPolicies.exponential(3) // Retry up to 3 times with exponential backoff
56
+ RetryPolicies.exponential(3), // Retry up to 3 times with exponential backoff
53
57
  );
54
58
  ```
55
59
 
@@ -65,9 +69,9 @@ interface UserResponse {
65
69
 
66
70
  try {
67
71
  const response = await adapter.send<UserResponse>(request);
68
- console.log("User created:", response.data);
72
+ console.log('User created:', response.data);
69
73
  } catch (error) {
70
- console.error("Request failed:", error);
74
+ console.error('Request failed:', error);
71
75
  }
72
76
  ```
73
77
 
@@ -80,7 +84,7 @@ Network instability is inevitable. This adapter allows you to define robust retr
80
84
  The built-in `ExponentialBackoffPolicy` waits increasingly longer between retries (e.g., 200ms, 400ms, 800ms) and adds random jitter to prevent "thundering herd" issues.
81
85
 
82
86
  ```typescript
83
- import { RetryPolicies } from "@yildizpay/http-adapter";
87
+ import { RetryPolicies } from '@yildizpay/http-adapter';
84
88
 
85
89
  // Retries on 429, 500, 502, 503, 504 and network errors
86
90
  const retryPolicy = RetryPolicies.exponential(5);
@@ -91,12 +95,12 @@ const retryPolicy = RetryPolicies.exponential(5);
91
95
  Interceptors allow you to hook into the lifecycle of a request. Implement the `HttpInterceptor` interface to create custom logic.
92
96
 
93
97
  ```typescript
94
- import { HttpInterceptor, Request, Response } from "@yildizpay/http-adapter";
98
+ import { HttpInterceptor, Request, Response } from '@yildizpay/http-adapter';
95
99
 
96
100
  export class LoggingInterceptor implements HttpInterceptor {
97
101
  async onRequest(request: Request): Promise<Request> {
98
102
  console.log(
99
- `[${request.systemCorrelationId}] Sending ${request.method} to ${request.endpoint}`
103
+ `[${request.systemCorrelationId}] Sending ${request.method} to ${request.endpoint}`,
100
104
  );
101
105
  return request;
102
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yildizpay/http-adapter",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Enterprise-grade HTTP Adapter for Node.js using Axios",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",