@alwatr/fetch 0.15.0 → 0.17.0

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/CHANGELOG.md CHANGED
@@ -3,13 +3,29 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- # [0.15.0](https://github.com/AliMD/alwatr/compare/v0.14.0...v0.15.0) (2022-09-01)
6
+ # [0.17.0](https://github.com/AliMD/alwatr/compare/v0.16.1...v0.17.0) (2022-10-21)
7
7
 
8
- **Note:** Version bump only for package @alwatr/fetch
8
+ ### Bug Fixes
9
+
10
+ - **fetch:** not ok retry condition ([0da1edd](https://github.com/AliMD/alwatr/commit/0da1edda64ec5abf70a83361d159e207691e368e))
11
+
12
+ ### Features
9
13
 
14
+ - **fetch:** docs & pattern ([459ad1c](https://github.com/AliMD/alwatr/commit/459ad1c5996f851769306639136d79c0f7270770))
15
+ - **fetch:** logger & jsdocs ([36f652d](https://github.com/AliMD/alwatr/commit/36f652d5dad23b2aeb824af77d1b0e442119c6e8))
16
+ - **fetch:** retry pattern ([5350d1a](https://github.com/AliMD/alwatr/commit/5350d1a81b9134d598f46006a1baa880b280ea98))
10
17
 
18
+ ### Performance Improvements
11
19
 
20
+ - **fetch:** syntax ([1fdd02e](https://github.com/AliMD/alwatr/commit/1fdd02ec8b52e32a124b8d7c1d1c7fd7c993e3af))
12
21
 
22
+ # [0.16.0](https://github.com/AliMD/alwatr/compare/v0.15.0...v0.16.0) (2022-09-08)
23
+
24
+ **Note:** Version bump only for package @alwatr/fetch
25
+
26
+ # [0.15.0](https://github.com/AliMD/alwatr/compare/v0.14.0...v0.15.0) (2022-09-01)
27
+
28
+ **Note:** Version bump only for package @alwatr/fetch
13
29
 
14
30
  # [0.14.0](https://github.com/AliMD/alwatr/compare/v0.13.0...v0.14.0) (2022-08-19)
15
31
 
package/README.md CHANGED
@@ -6,15 +6,54 @@ Enhanced fetch API with the timeout, helper methods, and types written in tiny T
6
6
 
7
7
  `Options` inherited from the `RequestInit`. you can watch all documents of the parameters RequestInit in [`fetch init parameters`](https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters)
8
8
 
9
- Options have two other parameters:
9
+ Options have some other parameters:
10
10
 
11
- - `bodyObject`: a JSON object that converts to string and put on the body.
12
- - `queryParameters`: a JSON object that converts to URL query params
11
+ - `bodyJson`: a JSON object that converts to string and put on the body.
12
+ - `queryParameters`: a JSON object that converts to URL query params.
13
+ - `timeout`: A timeout for the fetch request.
14
+ - `retry` If fetch response not acceptable or timed out, it will retry the request
13
15
 
14
16
  ## Example usage
15
17
 
16
- ```js
18
+ ```ts
17
19
  import {getJson} from 'https://esm.run/@alwatr/fetch';
18
20
 
19
- const productList = await getJson('/api/products', {limit: 10}, {timeout: 5_000});
21
+ interface ProductInterface {
22
+ _id: string;
23
+ name: string;
24
+ description: string;
25
+ image: string;
26
+ }
27
+
28
+ const productList = await getJson<Record<string, ProductInterface>>('/api/products', {
29
+ queryParameters: {limit: 10},
30
+ timeout: 15_000,
31
+ retry: 5,
32
+ });
33
+ ```
34
+
35
+ ## API
36
+
37
+ ### `fetch(url: string, options: FetchOptions = {})`
38
+
39
+ It's a wrapper around the browser's `fetch` function that adds retry pattern with timeout
40
+
41
+ ```ts
42
+ await fetch(url, {timeout: 5_000, bodyJson: {a: 1, b: 2}});
43
+ ```
44
+
45
+ ### `getJson(url: string, options: FetchOptions = {})`
46
+
47
+ It fetches a JSON file from a URL, and returns the JSON data
48
+
49
+ ```ts
50
+ await getJson('/api/products', {queryParameters: {limit: 10}, timeout: 5_000});
51
+ ```
52
+
53
+ ### `postJson(url: string, bodyJson: Record<string | number, unknown>, options?: FetchOptions)`
54
+
55
+ It takes a URL, a JSON object, and an optional FetchOptions object, and returns a Promise of a Response object
56
+
57
+ ```ts
58
+ await postJson(url, {first_name: 'foo', last_name: 'bar'});
20
59
  ```
package/fetch.d.ts CHANGED
@@ -5,33 +5,49 @@ declare global {
5
5
  }
6
6
  export interface FetchOptions extends RequestInit {
7
7
  /**
8
- * @default 10_000 ms
8
+ * A timeout for the fetch request.
9
+ *
10
+ * @default 5000 ms
9
11
  */
10
12
  timeout?: number;
11
- bodyObject?: Record<string | number, unknown>;
13
+ /**
14
+ * If fetch response not acceptable or timed out, it will retry the request.
15
+ *
16
+ * @default 3
17
+ */
18
+ retry?: number;
19
+ bodyJson?: Record<string | number, unknown>;
12
20
  queryParameters?: Record<string, string | number | boolean>;
13
21
  }
14
22
  /**
15
- * Enhanced base fetch API.
16
- * @example const response = await fetch(url, {jsonResponse: false});
23
+ * It's a wrapper around the browser's `fetch` function that adds retry pattern with timeout
24
+ *
25
+ * Example:
26
+ *
27
+ * ```ts
28
+ * const response = await fetch(url, {timeout: 5_000, bodyJson: {a: 1, b: 2}});
29
+ * ```
17
30
  */
18
31
  export declare function fetch(url: string, options?: FetchOptions): Promise<Response>;
19
32
  /**
20
- * Enhanced get data.
21
- * @example
22
- * const response = await postData('/api/products', {limit: 10}, {timeout: 5_000});
23
- */
24
- export declare function getData(url: string, queryParameters?: Record<string | number, string | number | boolean>, options?: FetchOptions): Promise<Response>;
25
- /**
26
- * Enhanced fetch JSON.
27
- * @example
28
- * const productList = await getJson('/api/products', {limit: 10}, {timeout: 5_000});
33
+ * It fetches a JSON file from a URL, and returns the JSON data
34
+ *
35
+ * Example:
36
+ *
37
+ * ```ts
38
+ * const productList = await getJson<ProductResponse>('/api/products', {queryParameters: {limit: 10}, timeout: 5_000});
39
+ * ```
29
40
  */
30
- export declare function getJson<ResponseType extends Record<string | number, unknown>>(url: string, queryParameters?: Record<string | number, string | number | boolean>, options?: FetchOptions): Promise<ResponseType>;
41
+ export declare function getJson<ResponseType extends Record<string | number, unknown>>(url: string, options?: FetchOptions): Promise<ResponseType>;
31
42
  /**
32
- * Enhanced post json data.
33
- * @example
34
- * const response = await postData('/api/product/new', {name: 'foo', ...});
43
+ * It takes a URL, a JSON object, and an optional FetchOptions object, and returns a Promise of a
44
+ * Response object
45
+ *
46
+ * Example:
47
+ *
48
+ * ```ts
49
+ * const response = await postJson('/api/product/new', {name: 'foo', ...});
50
+ * ```
35
51
  */
36
- export declare function postData(url: string, body: Record<string | number, unknown>, options?: FetchOptions): Promise<Response>;
52
+ export declare function postJson(url: string, bodyJson: Record<string | number, unknown>, options?: FetchOptions): Promise<Response>;
37
53
  //# sourceMappingURL=fetch.d.ts.map
package/fetch.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["src/fetch.ts"],"names":[],"mappings":"AASA,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,eAAe;QACvB,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC9B;CACF;AAGD,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9C,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CAC7D;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CA0D5E;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CACnB,GAAG,EAAE,MAAM,EACX,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EACpE,OAAO,CAAC,EAAE,YAAY,GACvB,OAAO,CAAC,QAAQ,CAAC,CAMnB;AAED;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,YAAY,SAAS,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAC/E,GAAG,EAAE,MAAM,E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,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAC1C,OAAO,CAAC,EAAE,YAAY,GACvB,OAAO,CAAC,QAAQ,CAAC,CAQnB"}
package/fetch.js CHANGED
@@ -5,22 +5,25 @@ alwatrRegisteredList.push({
5
5
  version: '{{ALWATR_VERSION}}',
6
6
  });
7
7
  /**
8
- * Enhanced base fetch API.
9
- * @example const response = await fetch(url, {jsonResponse: false});
8
+ * It's a wrapper around the browser's `fetch` function that adds retry pattern with timeout
9
+ *
10
+ * Example:
11
+ *
12
+ * ```ts
13
+ * const response = await fetch(url, {timeout: 5_000, bodyJson: {a: 1, b: 2}});
14
+ * ```
10
15
  */
11
- export function fetch(url, options) {
16
+ export function fetch(url, options = {}) {
12
17
  logger.logMethodArgs('fetch', { url, options });
13
- if (!navigator.onLine) {
14
- logger.accident('fetch', 'abort_signal', 'abort signal received', { url });
15
- throw new Error('fetch_offline');
16
- }
17
- options = {
18
- method: 'GET',
19
- timeout: 15000,
20
- window: null,
21
- ...options,
22
- };
23
- if (options.queryParameters != null) {
18
+ // if (!navigator.onLine) {
19
+ // logger.accident('fetch', 'abort_signal', 'abort signal received', {url});
20
+ // throw new Error('fetch_offline');
21
+ // }
22
+ options.method ?? (options.method = 'GET');
23
+ options.timeout ?? (options.timeout = 5000);
24
+ options.retry ?? (options.retry = 3);
25
+ options.window ?? (options.window = null);
26
+ if (url.lastIndexOf('?') === -1 && options.queryParameters != null) {
24
27
  // prettier-ignore
25
28
  const queryArray = Object
26
29
  .keys(options.queryParameters)
@@ -30,8 +33,8 @@ export function fetch(url, options) {
30
33
  url += '?' + queryArray.join('&');
31
34
  }
32
35
  }
33
- if (options.bodyObject != null) {
34
- options.body = JSON.stringify(options.bodyObject);
36
+ if (options.body != null && options.bodyJson != null) {
37
+ options.body = JSON.stringify(options.bodyJson);
35
38
  options.headers = {
36
39
  ...options.headers,
37
40
  'Content-Type': 'application/json',
@@ -40,10 +43,17 @@ export function fetch(url, options) {
40
43
  // @TODO: AbortController polyfill
41
44
  const abortController = new AbortController();
42
45
  const externalAbortSignal = options.signal;
46
+ options.signal = abortController.signal;
47
+ let timedOut = false;
48
+ const timeoutId = setTimeout(() => {
49
+ abortController.abort('fetch_timeout');
50
+ timedOut = true;
51
+ }, options.timeout);
43
52
  if (externalAbortSignal != null) {
44
53
  // Respect external abort signal
45
54
  externalAbortSignal.addEventListener('abort', () => {
46
55
  abortController.abort(`external abort signal: ${externalAbortSignal.reason}`);
56
+ clearTimeout(timeoutId);
47
57
  });
48
58
  }
49
59
  abortController.signal.addEventListener('abort', () => {
@@ -52,48 +62,90 @@ export function fetch(url, options) {
52
62
  reason: abortController.signal.reason,
53
63
  });
54
64
  });
55
- options.signal = abortController.signal;
56
- const timeoutId = setTimeout(() => abortController.abort('fetch_timeout'), options.timeout);
57
65
  // @TODO: browser fetch polyfill
58
66
  const response = window.fetch(url, options);
59
- response.then(() => clearTimeout(timeoutId));
60
- return response;
61
- }
62
- /**
63
- * Enhanced get data.
64
- * @example
65
- * const response = await postData('/api/products', {limit: 10}, {timeout: 5_000});
66
- */
67
- export function getData(url, queryParameters, options) {
68
- logger.logMethodArgs('getData', { url, queryParameters, options });
69
- return fetch(url, {
70
- queryParameters,
71
- ...options,
67
+ return response
68
+ .then((response) => {
69
+ clearTimeout(timeoutId);
70
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
71
+ if (response.status >= 502 && response.status <= 504 && options.retry > 1) {
72
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
73
+ options.retry--;
74
+ options.signal = externalAbortSignal;
75
+ logger.accident('fetch', 'fetch_nok', 'fetch not ok and retry', {
76
+ retry: options.retry,
77
+ response,
78
+ });
79
+ return fetch(url, options);
80
+ }
81
+ return response;
82
+ })
83
+ .catch((reason) => {
84
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
85
+ if (timedOut && options.retry > 1) {
86
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
87
+ options.retry--;
88
+ options.signal = externalAbortSignal;
89
+ logger.accident('fetch', 'fetch_catch', 'fetch catch and retry', {
90
+ retry: options.retry,
91
+ reason,
92
+ });
93
+ return fetch(url, options);
94
+ }
95
+ else {
96
+ throw reason;
97
+ }
72
98
  });
73
99
  }
74
100
  /**
75
- * Enhanced fetch JSON.
76
- * @example
77
- * const productList = await getJson('/api/products', {limit: 10}, {timeout: 5_000});
101
+ * It fetches a JSON file from a URL, and returns the JSON data
102
+ *
103
+ * Example:
104
+ *
105
+ * ```ts
106
+ * const productList = await getJson<ProductResponse>('/api/products', {queryParameters: {limit: 10}, timeout: 5_000});
107
+ * ```
78
108
  */
79
- export async function getJson(url, queryParameters, options) {
80
- logger.logMethodArgs('getJson', { url, queryParameters, options });
81
- const response = await getData(url, queryParameters, options);
82
- if (!response.ok) {
83
- throw new Error('fetch_nok');
109
+ export async function getJson(url, options = {}) {
110
+ logger.logMethodArgs('getJson', { url, options });
111
+ const response = await fetch(url, options);
112
+ let data;
113
+ try {
114
+ if (!response.ok) {
115
+ throw new Error('fetch_nok');
116
+ }
117
+ data = (await response.json());
118
+ }
119
+ catch (err) {
120
+ logger.accident('getJson', 'response_json', 'response json error', {
121
+ retry: options.retry,
122
+ err,
123
+ });
124
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
125
+ if (options.retry > 1) {
126
+ data = await getJson(url, options);
127
+ }
128
+ else {
129
+ throw err;
130
+ }
84
131
  }
85
- return response.json();
132
+ return data;
86
133
  }
87
134
  /**
88
- * Enhanced post json data.
89
- * @example
90
- * const response = await postData('/api/product/new', {name: 'foo', ...});
135
+ * It takes a URL, a JSON object, and an optional FetchOptions object, and returns a Promise of a
136
+ * Response object
137
+ *
138
+ * Example:
139
+ *
140
+ * ```ts
141
+ * const response = await postJson('/api/product/new', {name: 'foo', ...});
142
+ * ```
91
143
  */
92
- export function postData(url, body, options) {
93
- logger.logMethodArgs('postData', { url, body, options });
144
+ export function postJson(url, bodyJson, options) {
145
+ logger.logMethod('postJson');
94
146
  return fetch(url, {
95
147
  method: 'POST',
96
- bodyObject: body,
148
+ bodyJson,
97
149
  ...options,
98
150
  });
99
151
  }
package/fetch.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sourceRoot":"","sources":["src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AAElE,MAAM,MAAM,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;AAE5C,oBAAoB,CAAC,IAAI,CAAC;IACxB,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,oBAAoB;CAC9B,CAAC,CAAC;AAmBH;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,GAAW,EAAE,OAAsB;IACvD,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,EAAC,GAAG,EAAE,OAAO,EAAC,CAAC,CAAC;IAE9C,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE;QACrB,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,EAAC,GAAG,EAAC,CAAC,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;KAClC;IAED,OAAO,GAAG;QACR,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,KAAM;QACf,MAAM,EAAE,IAAI;QACZ,GAAG,OAAO;KACX,CAAC;IAEF,IAAI,OAAO,CAAC,eAAe,IAAI,IAAI,EAAE;QACnC,kBAAkB;QAClB,MAAM,UAAU,GAAG,MAAM;aACpB,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;YAC9B,oEAAoE;aACnE,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,MAAM,CAAC,OAAQ,CAAC,eAAgB,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QAEtE,IAAI,UAAU,CAAC,MAAM,GAAG,CAA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E,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;SAC9B;QACD,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAiB,CAAC;KAChD;IACD,OAAO,GAAG,EAAE;QACV,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,eAAe,EAAE,qBAAqB,EAAE;YACjE,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,GAAG;SACJ,CAAC,CAAC;QAEH,oEAAoE;QACpE,IAAI,OAAO,CAAC,KAAM,GAAG,CAAC,EAAE;YACtB,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;SACpC;aACI;YACH,MAAM,GAAG,CAAC;SACX;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CACpB,GAAW,EACX,QAA0C,EAC1C,OAAsB;IAExB,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAE7B,OAAO,KAAK,CAAC,GAAG,EAAE;QAChB,MAAM,EAAE,MAAM;QACd,QAAQ;QACR,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwatr/fetch",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "Enhanced fetch api with timeout, helper methods and types written in tiny TypeScript module.",
5
5
  "keywords": [
6
6
  "fetch",
@@ -32,8 +32,8 @@
32
32
  "url": "https://github.com/AliMD/alwatr/issues"
33
33
  },
34
34
  "dependencies": {
35
- "@alwatr/logger": "^0.15.0",
35
+ "@alwatr/logger": "^0.17.0",
36
36
  "tslib": "^2.3.1"
37
37
  },
38
- "gitHead": "785516d9da483e429ed9b79b3c6d71012c9aa822"
38
+ "gitHead": "f531925ca3db1072c0eaea90cb18e00802c93247"
39
39
  }