@emmvish/stable-request 1.1.5 → 1.1.6
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.
- package/README.md +28 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,15 +29,19 @@ npm install @emmvish/stable-request
|
|
|
29
29
|
```typescript
|
|
30
30
|
import { stableRequest } from '@emmvish/stable-request';
|
|
31
31
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
const getStableResponse = async () => {
|
|
33
|
+
const data = await stableRequest({
|
|
34
|
+
reqData: {
|
|
35
|
+
hostname: 'api.example.com',
|
|
36
|
+
path: '/users/123'
|
|
37
|
+
},
|
|
38
|
+
resReq: true // Return the response data
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
console.log(data); // { id: 123, name: 'John' }
|
|
42
|
+
}
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
getStableResponse();
|
|
41
45
|
```
|
|
42
46
|
|
|
43
47
|
### 2. Add Simple Retries
|
|
@@ -45,16 +49,22 @@ console.log(data); // { id: 123, name: 'John' }
|
|
|
45
49
|
```typescript
|
|
46
50
|
import { stableRequest, RETRY_STRATEGIES } from '@emmvish/stable-request';
|
|
47
51
|
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
const getStableResponse = async () => {
|
|
53
|
+
const data = await stableRequest({
|
|
54
|
+
reqData: {
|
|
55
|
+
hostname: 'api.example.com',
|
|
56
|
+
path: '/users/123'
|
|
57
|
+
},
|
|
58
|
+
resReq: true,
|
|
59
|
+
attempts: 3, // Retry up to 3 times
|
|
60
|
+
wait: 1000, // Wait 1 second between retries
|
|
61
|
+
retryStrategy: RETRY_STRATEGIES.EXPONENTIAL // 1s, 2s, 4s, 8s...
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
console.log(data);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getStableResponse();
|
|
58
68
|
```
|
|
59
69
|
|
|
60
70
|
**Retry Strategies:**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emmvish/stable-request",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "stable-request is a TypeScript-first HTTP reliability toolkit for workflow-driven API integrations, that goes beyond status-code retries by validating response content, handling eventual consistency, coordinating batch workflows with intelligent grouping, and providing deep observability into every request attempt. It is designed for real-world distributed systems where HTTP success does not guarantee business success. It also provides extensive support for managing multiple requests so as to achieve workflow automation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|