@emmvish/stable-request 1.1.5 → 1.1.7

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 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 data = await stableRequest({
33
- reqData: {
34
- hostname: 'api.example.com',
35
- path: '/users/123'
36
- },
37
- resReq: true // Return the response data
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
- console.log(data); // { id: 123, name: 'John' }
44
+ getStableResponse();
41
45
  ```
42
46
 
43
47
  ### 2. Add Simple Retries
@@ -45,16 +49,23 @@ console.log(data); // { id: 123, name: 'John' }
45
49
  ```typescript
46
50
  import { stableRequest, RETRY_STRATEGIES } from '@emmvish/stable-request';
47
51
 
48
- const data = await stableRequest({
49
- reqData: {
50
- hostname: 'api.example.com',
51
- path: '/users/123'
52
- },
53
- resReq: true,
54
- attempts: 3, // Retry up to 3 times
55
- wait: 1000, // Wait 1 second between retries
56
- retryStrategy: RETRY_STRATEGIES.EXPONENTIAL // 1s, 2s, 4s, 8s...
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
+ maxAllowedWait: 8000, // Maximum permissible wait time between retries
62
+ retryStrategy: RETRY_STRATEGIES.EXPONENTIAL // 1s, 2s, 4s, 8s...
63
+ });
64
+
65
+ console.log(data);
66
+ }
67
+
68
+ getStableResponse();
58
69
  ```
59
70
 
60
71
  **Retry Strategies:**
@@ -15,7 +15,7 @@ export async function executeSequentially(requests = [], requestExecutionOptions
15
15
  ...(req.groupId && { groupId: req.groupId }),
16
16
  success: res ? true : false,
17
17
  ...(res && { data: res }),
18
- ...(!res && { error: 'Request was unsuccessful, but analyzed successfully!' })
18
+ ...(!res && { error: 'Request was unsuccessful, but the error was analyzed successfully!' })
19
19
  });
20
20
  }
21
21
  catch (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"execute-sequentially.js","sourceRoot":"","sources":["../../src/utilities/execute-sequentially.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAO5E,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACrC,WAAqE,EAAE,EACvE,0BAAmG,EAAE;IAErG,MAAM,SAAS,GAA6C,EAAE,CAAC;IAC/D,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,CAAC;YACD,MAAM,mBAAmB,GAAG;gBACxB,OAAO,EAAE,qBAAqB,CAAoC,GAAG,EAAE,uBAAuB,CAAC;gBAC/F,GAAG,wBAAwB,CAAoC,GAAG,EAAE,uBAAuB,CAAC;aAC/F,CAAC;YACF,MAAM,GAAG,GAAG,MAAM,aAAa,CAAoC,mBAAmB,CAAC,CAAC;YACxF,SAAS,CAAC,IAAI,CAAC;gBACX,SAAS,EAAE,GAAG,CAAC,EAAE;gBACjB,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;gBAC5C,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;gBAC3B,GAAG,CAAC,GAAG,IAAI,EAAE,IAAI,EAAE,GAAuB,EAAE,CAAC;gBAC7C,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,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OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;gBAC5C,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;gBAC3B,GAAG,CAAC,GAAG,IAAI,EAAE,IAAI,EAAE,GAAuB,EAAE,CAAC;gBAC7C,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,oEAAoE,EAAE,CAAC;aAC/F,CAAC,CAAA;QACN,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACb,SAAS,CAAC,IAAI,CAAC;gBACX,SAAS,EAAE,GAAG,CAAC,EAAE;gBACjB,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;gBAC5C,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,CAAC,EAAE,OAAO,IAAI,sDAAsD;aAC9E,CAAC,CAAC;YACH,IAAG,uBAAuB,CAAC,gBAAgB,EAAE,CAAC;gBAC1C,MAAM;YACV,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emmvish/stable-request",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
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",