lambda-essentials-ts 5.1.6 → 5.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/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
6
 
7
+ ## [5.1.7] - 2022-12-13
8
+
9
+ ### Changed
10
+
11
+ Add timeout option in HttpClient. If no value is provided the default is no timeout.
12
+
7
13
  ## [5.1.6] - 2022-11-30
8
14
 
9
15
  ### Changed
package/README.md CHANGED
@@ -69,6 +69,7 @@ let httpClient = new HttpClient({
69
69
  query: false, // also cache requests with query parameters
70
70
  },
71
71
  },
72
+ timeout: 1000
72
73
  });
73
74
 
74
75
  let headers = {};
@@ -16,6 +16,7 @@ export default class HttpClient {
16
16
  private readonly client;
17
17
  private readonly enableRetry;
18
18
  private readonly enableCache;
19
+ private readonly timeout?;
19
20
  /**
20
21
  * Create a new Instance of the HttpClient
21
22
  */
@@ -94,6 +95,11 @@ export interface HttpClientOptions {
94
95
  * @link https://github.com/JustinBeckwith/retry-axios/blob/v2.6.0/src/index.ts#L11
95
96
  */
96
97
  retryOptions?: RetryConfig;
98
+ /**
99
+ * Number of milliseconds before the request times out. Default or `0` is no time out.
100
+ * @link https://github.com/axios/axios/blob/main/README.md#request-config
101
+ */
102
+ timeout?: number;
97
103
  }
98
104
  /**
99
105
  * Log options object.
@@ -61,6 +61,7 @@ class HttpClient {
61
61
  this.correlationIdResolverFunction = options === null || options === void 0 ? void 0 : options.correlationIdResolver;
62
62
  this.enableCache = (_c = options === null || options === void 0 ? void 0 : options.enableCache) !== null && _c !== void 0 ? _c : false;
63
63
  this.enableRetry = (_d = options === null || options === void 0 ? void 0 : options.enableRetry) !== null && _d !== void 0 ? _d : false;
64
+ this.timeout = options === null || options === void 0 ? void 0 : options.timeout;
64
65
  this.client =
65
66
  (_e = options === null || options === void 0 ? void 0 : options.client) !== null && _e !== void 0 ? _e : axios_1.default.create({
66
67
  adapter: (() => {
@@ -101,6 +102,9 @@ class HttpClient {
101
102
  // attach retry-axios
102
103
  rax.attach(this.client);
103
104
  }
105
+ if (this.timeout) {
106
+ this.client.defaults.timeout = this.timeout;
107
+ }
104
108
  this.client.interceptors.request.use((config) => {
105
109
  if (this.logOptions.enabledLogs.includes(HttpLogType.requests)) {
106
110
  this.logFunction({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambda-essentials-ts",
3
- "version": "5.1.6",
3
+ "version": "5.1.7",
4
4
  "description": "A selection of the finest modules supporting authorization, API routing, error handling, logging and sending HTTP requests.",
5
5
  "main": "lib/index.js",
6
6
  "private": false,