@pristine-ts/http 0.0.231 → 0.0.233
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/dist/lib/cjs/clients/http.client.js +2 -3
- package/dist/lib/cjs/clients/http.client.js.map +1 -1
- package/dist/lib/cjs/http.module.js +11 -1
- package/dist/lib/cjs/http.module.js.map +1 -1
- package/dist/lib/cjs/interceptors/http-error-response-logging.interceptor.js +7 -3
- package/dist/lib/cjs/interceptors/http-error-response-logging.interceptor.js.map +1 -1
- package/dist/lib/cjs/interceptors/http-request-logging.interceptor.js +7 -3
- package/dist/lib/cjs/interceptors/http-request-logging.interceptor.js.map +1 -1
- package/dist/lib/cjs/interceptors/http-response-logging.interceptor.js +7 -3
- package/dist/lib/cjs/interceptors/http-response-logging.interceptor.js.map +1 -1
- package/dist/lib/cjs/utils/url.utils.js +15 -0
- package/dist/lib/cjs/utils/url.utils.js.map +1 -0
- package/dist/lib/cjs/utils/utils.js +1 -0
- package/dist/lib/cjs/utils/utils.js.map +1 -1
- package/dist/lib/esm/clients/http.client.js +2 -3
- package/dist/lib/esm/clients/http.client.js.map +1 -1
- package/dist/lib/esm/http.module.js +11 -1
- package/dist/lib/esm/http.module.js.map +1 -1
- package/dist/lib/esm/interceptors/http-error-response-logging.interceptor.js +7 -3
- package/dist/lib/esm/interceptors/http-error-response-logging.interceptor.js.map +1 -1
- package/dist/lib/esm/interceptors/http-request-logging.interceptor.js +7 -3
- package/dist/lib/esm/interceptors/http-request-logging.interceptor.js.map +1 -1
- package/dist/lib/esm/interceptors/http-response-logging.interceptor.js +7 -3
- package/dist/lib/esm/interceptors/http-response-logging.interceptor.js.map +1 -1
- package/dist/lib/esm/utils/url.utils.js +11 -0
- package/dist/lib/esm/utils/url.utils.js.map +1 -0
- package/dist/lib/esm/utils/utils.js +1 -0
- package/dist/lib/esm/utils/utils.js.map +1 -1
- package/dist/types/interceptors/http-error-response-logging.interceptor.d.ts +2 -1
- package/dist/types/interceptors/http-request-logging.interceptor.d.ts +2 -1
- package/dist/types/interceptors/http-response-logging.interceptor.d.ts +2 -1
- package/dist/types/utils/url.utils.d.ts +5 -0
- package/dist/types/utils/utils.d.ts +1 -0
- package/package.json +4 -4
|
@@ -29,6 +29,7 @@ const lodash_1 = require("lodash");
|
|
|
29
29
|
const common_1 = require("@pristine-ts/common");
|
|
30
30
|
const math_utils_1 = require("../utils/math.utils");
|
|
31
31
|
const http_client_response_redirect_error_1 = require("../errors/http-client-response-redirect.error");
|
|
32
|
+
const url_utils_1 = require("../utils/url.utils");
|
|
32
33
|
/**
|
|
33
34
|
* This service is an http client for any http request you need to make outside of Pristine.
|
|
34
35
|
*/
|
|
@@ -181,9 +182,7 @@ let HttpClient = class HttpClient {
|
|
|
181
182
|
}
|
|
182
183
|
const updatedRequest = request;
|
|
183
184
|
// Updated the URL by using the 'location' header returned by the response.
|
|
184
|
-
|
|
185
|
-
url.pathname = response.headers.location;
|
|
186
|
-
updatedRequest.url = url.toString();
|
|
185
|
+
updatedRequest.url = url_utils_1.UrlUtils.appendLocationHeaderToUrl(new url_1.URL(request.url), response.headers.location).toString();
|
|
187
186
|
const updatedRedirectCount = ++currentRedirectCount;
|
|
188
187
|
// Retry the request using an exponential backoff with jitter.
|
|
189
188
|
updatedResponse = yield this.httpWrapper.executeRequest(updatedRequest);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.client.js","sourceRoot":"","sources":["../../../../src/clients/http.client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuD;AAIvD,6BAA0B;AAC1B,oEAA6D;AAE7D,mCAA8B;AAC9B,gDAAkE;AAGlE,oDAA8C;AAC9C,uGAA8F;
|
|
1
|
+
{"version":3,"file":"http.client.js","sourceRoot":"","sources":["../../../../src/clients/http.client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuD;AAIvD,6BAA0B;AAC1B,oEAA6D;AAE7D,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,CAAC,QAA+B;QACtD,OAAO,QAAQ,CAAC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAC;IAC3D,CAAC;CACJ,CAAA;AA/LY,UAAU;IAFtB,IAAA,YAAG,EAAC,qBAAqB,CAAC;IAC1B,IAAA,qBAAU,GAAE;IAmBI,WAAA,IAAA,iBAAM,EAAC,sBAAsB,CAAC,CAAA;IAC9B,WAAA,IAAA,oBAAS,EAAC,iCAAwB,CAAC,sBAAsB,CAAC,CAAA;IAC1D,WAAA,IAAA,oBAAS,EAAC,iCAAwB,CAAC,uBAAuB,CAAC,CAAA;IAC3D,WAAA,IAAA,oBAAS,EAAC,iCAAwB,CAAC,4BAA4B,CAAC,CAAA;;GArBpE,UAAU,CA+LtB;AA/LY,gCAAU"}
|
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.HttpModule = void 0;
|
|
18
18
|
const http_module_keyname_1 = require("./http.module.keyname");
|
|
19
19
|
const logging_1 = require("@pristine-ts/logging");
|
|
20
|
+
const configuration_1 = require("@pristine-ts/configuration");
|
|
20
21
|
__exportStar(require("./clients/clients"), exports);
|
|
21
22
|
__exportStar(require("./enums/enums"), exports);
|
|
22
23
|
__exportStar(require("./errors/errors"), exports);
|
|
@@ -28,6 +29,15 @@ __exportStar(require("./wrappers/wrappers"), exports);
|
|
|
28
29
|
exports.HttpModule = {
|
|
29
30
|
keyname: http_module_keyname_1.HttpModuleKeyname,
|
|
30
31
|
importModules: [logging_1.LoggingModule],
|
|
31
|
-
configurationDefinitions: [
|
|
32
|
+
configurationDefinitions: [
|
|
33
|
+
{
|
|
34
|
+
parameterName: "pristine.http.logging-enabled",
|
|
35
|
+
defaultValue: true,
|
|
36
|
+
isRequired: false,
|
|
37
|
+
defaultResolvers: [
|
|
38
|
+
new configuration_1.BooleanResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_HTTP_LOGGING")),
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
],
|
|
32
42
|
};
|
|
33
43
|
//# sourceMappingURL=http.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.module.js","sourceRoot":"","sources":["../../../src/http.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,+DAAwD;AACxD,kDAAmD;
|
|
1
|
+
{"version":3,"file":"http.module.js","sourceRoot":"","sources":["../../../src/http.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,+DAAwD;AACxD,kDAAmD;AACnD,8DAAwF;AAExF,oDAAkC;AAClC,gDAA8B;AAC9B,kDAAgC;AAChC,8DAA2C;AAC3C,0DAAuC;AACvC,oDAAkC;AAClC,gDAA8B;AAC9B,sDAAoC;AAEvB,QAAA,UAAU,GAAoB;IACvC,OAAO,EAAE,uCAAiB;IAC1B,aAAa,EAAE,CAAC,uBAAa,CAAC;IAC9B,wBAAwB,EAAE;QACtB;YACI,aAAa,EAAE,+BAA+B;YAC9C,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,+BAAe,CAAC,IAAI,2CAA2B,CAAC,uBAAuB,CAAC,CAAC;aAChF;SACJ;KACJ;CACJ,CAAA"}
|
|
@@ -31,8 +31,9 @@ const http_module_keyname_1 = require("../http.module.keyname");
|
|
|
31
31
|
* It is module scoped to the http module so that it is only registered if the http module is imported.
|
|
32
32
|
*/
|
|
33
33
|
let HttpErrorResponseLoggingInterceptor = class HttpErrorResponseLoggingInterceptor {
|
|
34
|
-
constructor(logHandler) {
|
|
34
|
+
constructor(logHandler, loggingEnabled) {
|
|
35
35
|
this.logHandler = logHandler;
|
|
36
|
+
this.loggingEnabled = loggingEnabled;
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* This method intercepts an incoming http response that has an error and logs it.
|
|
@@ -42,7 +43,9 @@ let HttpErrorResponseLoggingInterceptor = class HttpErrorResponseLoggingIntercep
|
|
|
42
43
|
*/
|
|
43
44
|
interceptErrorResponse(request, options, response) {
|
|
44
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
this.
|
|
46
|
+
if (this.loggingEnabled) {
|
|
47
|
+
this.logHandler.error("Receiving http response that has an error", { response, options }, http_module_keyname_1.HttpModuleKeyname);
|
|
48
|
+
}
|
|
46
49
|
return response;
|
|
47
50
|
});
|
|
48
51
|
}
|
|
@@ -52,7 +55,8 @@ HttpErrorResponseLoggingInterceptor = __decorate([
|
|
|
52
55
|
(0, common_1.moduleScoped)(http_module_keyname_1.HttpModuleKeyname),
|
|
53
56
|
(0, tsyringe_1.injectable)(),
|
|
54
57
|
__param(0, (0, tsyringe_1.inject)("LogHandlerInterface")),
|
|
55
|
-
|
|
58
|
+
__param(1, (0, tsyringe_1.inject)("%pristine.http.logging-enabled%")),
|
|
59
|
+
__metadata("design:paramtypes", [Object, Boolean])
|
|
56
60
|
], HttpErrorResponseLoggingInterceptor);
|
|
57
61
|
exports.HttpErrorResponseLoggingInterceptor = HttpErrorResponseLoggingInterceptor;
|
|
58
62
|
//# sourceMappingURL=http-error-response-logging.interceptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-error-response-logging.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/http-error-response-logging.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAC5C,gDAAkF;AAKlF,gEAAyD;AAGzD;;;;GAIG;AAII,IAAM,mCAAmC,GAAzC,MAAM,mCAAmC;IAC5C,
|
|
1
|
+
{"version":3,"file":"http-error-response-logging.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/http-error-response-logging.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAC5C,gDAAkF;AAKlF,gEAAyD;AAGzD;;;;GAIG;AAII,IAAM,mCAAmC,GAAzC,MAAM,mCAAmC;IAC5C,YACoD,UAA+B,EACnB,cAAuB;QADnC,eAAU,GAAV,UAAU,CAAqB;QACnB,mBAAc,GAAd,cAAc,CAAS;IAEvF,CAAC;IAED;;;;;OAKG;IACG,sBAAsB,CAAC,OAA6B,EAAE,OAA2B,EAAE,QAA+B;;YACpH,IAAG,IAAI,CAAC,cAAc,EAAE;gBACpB,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,2CAA2C,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,EAAE,uCAAiB,CAAC,CAAC;aAC9G;YAED,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;CAEJ,CAAA;AArBY,mCAAmC;IAH/C,IAAA,YAAG,EAAC,iCAAwB,CAAC,4BAA4B,CAAC;IAC1D,IAAA,qBAAY,EAAC,uCAAiB,CAAC;IAC/B,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,IAAA,iBAAM,EAAC,iCAAiC,CAAC,CAAA;;GAHrC,mCAAmC,CAqB/C;AArBY,kFAAmC"}
|
|
@@ -31,8 +31,9 @@ const http_module_keyname_1 = require("../http.module.keyname");
|
|
|
31
31
|
* It is module scoped to the http module so that it is only registered if the http module is imported.
|
|
32
32
|
*/
|
|
33
33
|
let HttpRequestLoggingInterceptor = class HttpRequestLoggingInterceptor {
|
|
34
|
-
constructor(logHandler) {
|
|
34
|
+
constructor(logHandler, loggingEnabled) {
|
|
35
35
|
this.logHandler = logHandler;
|
|
36
|
+
this.loggingEnabled = loggingEnabled;
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* This method intercepts an outgoing http request and logs it.
|
|
@@ -41,7 +42,9 @@ let HttpRequestLoggingInterceptor = class HttpRequestLoggingInterceptor {
|
|
|
41
42
|
*/
|
|
42
43
|
interceptRequest(request, options) {
|
|
43
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
this.
|
|
45
|
+
if (this.loggingEnabled) {
|
|
46
|
+
this.logHandler.info("Outgoing http request", { request, options }, http_module_keyname_1.HttpModuleKeyname);
|
|
47
|
+
}
|
|
45
48
|
return request;
|
|
46
49
|
});
|
|
47
50
|
}
|
|
@@ -51,7 +54,8 @@ HttpRequestLoggingInterceptor = __decorate([
|
|
|
51
54
|
(0, common_1.moduleScoped)(http_module_keyname_1.HttpModuleKeyname),
|
|
52
55
|
(0, tsyringe_1.injectable)(),
|
|
53
56
|
__param(0, (0, tsyringe_1.inject)("LogHandlerInterface")),
|
|
54
|
-
|
|
57
|
+
__param(1, (0, tsyringe_1.inject)("%pristine.http.logging-enabled%")),
|
|
58
|
+
__metadata("design:paramtypes", [Object, Boolean])
|
|
55
59
|
], HttpRequestLoggingInterceptor);
|
|
56
60
|
exports.HttpRequestLoggingInterceptor = HttpRequestLoggingInterceptor;
|
|
57
61
|
//# sourceMappingURL=http-request-logging.interceptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-request-logging.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/http-request-logging.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAE5C,gDAAkF;AAIlF,gEAAyD;AAEzD;;;;GAIG;AAII,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IACtC,
|
|
1
|
+
{"version":3,"file":"http-request-logging.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/http-request-logging.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAE5C,gDAAkF;AAIlF,gEAAyD;AAEzD;;;;GAIG;AAII,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IACtC,YACoD,UAA+B,EACnB,cAAuB;QADnC,eAAU,GAAV,UAAU,CAAqB;QACnB,mBAAc,GAAd,cAAc,CAAS;IAEvF,CAAC;IAED;;;;OAIG;IACG,gBAAgB,CAAC,OAA6B,EAAE,OAA2B;;YAC7E,IAAG,IAAI,CAAC,cAAc,EAAE;gBACpB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAC,OAAO,EAAE,OAAO,EAAC,EAAE,uCAAiB,CAAC,CAAC;aACxF;YAED,OAAO,OAAO,CAAC;QACnB,CAAC;KAAA;CACJ,CAAA;AAnBY,6BAA6B;IAHzC,IAAA,YAAG,EAAC,iCAAwB,CAAC,sBAAsB,CAAC;IACpD,IAAA,qBAAY,EAAC,uCAAiB,CAAC;IAC/B,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,IAAA,iBAAM,EAAC,iCAAiC,CAAC,CAAA;;GAHrC,6BAA6B,CAmBzC;AAnBY,sEAA6B"}
|
|
@@ -31,8 +31,9 @@ const http_module_keyname_1 = require("../http.module.keyname");
|
|
|
31
31
|
* It is module scoped to the http module so that it is only registered if the http module is imported.
|
|
32
32
|
*/
|
|
33
33
|
let HttpResponseLoggingInterceptor = class HttpResponseLoggingInterceptor {
|
|
34
|
-
constructor(logHandler) {
|
|
34
|
+
constructor(logHandler, loggingEnabled) {
|
|
35
35
|
this.logHandler = logHandler;
|
|
36
|
+
this.loggingEnabled = loggingEnabled;
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* This method intercepts an incoming http response and logs it.
|
|
@@ -42,7 +43,9 @@ let HttpResponseLoggingInterceptor = class HttpResponseLoggingInterceptor {
|
|
|
42
43
|
*/
|
|
43
44
|
interceptResponse(request, options, response) {
|
|
44
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
this.
|
|
46
|
+
if (this.loggingEnabled) {
|
|
47
|
+
this.logHandler.info("Receiving http response", { response, options }, http_module_keyname_1.HttpModuleKeyname);
|
|
48
|
+
}
|
|
46
49
|
return response;
|
|
47
50
|
});
|
|
48
51
|
}
|
|
@@ -52,7 +55,8 @@ HttpResponseLoggingInterceptor = __decorate([
|
|
|
52
55
|
(0, common_1.moduleScoped)(http_module_keyname_1.HttpModuleKeyname),
|
|
53
56
|
(0, tsyringe_1.injectable)(),
|
|
54
57
|
__param(0, (0, tsyringe_1.inject)("LogHandlerInterface")),
|
|
55
|
-
|
|
58
|
+
__param(1, (0, tsyringe_1.inject)("%pristine.http.logging-enabled%")),
|
|
59
|
+
__metadata("design:paramtypes", [Object, Boolean])
|
|
56
60
|
], HttpResponseLoggingInterceptor);
|
|
57
61
|
exports.HttpResponseLoggingInterceptor = HttpResponseLoggingInterceptor;
|
|
58
62
|
//# sourceMappingURL=http-response-logging.interceptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-response-logging.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/http-response-logging.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAC5C,gDAAkF;AAMlF,gEAAyD;AAEzD;;;;GAIG;AAII,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IACvC,
|
|
1
|
+
{"version":3,"file":"http-response-logging.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/http-response-logging.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAC5C,gDAAkF;AAMlF,gEAAyD;AAEzD;;;;GAIG;AAII,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IACvC,YACoD,UAA+B,EACnB,cAAuB;QADnC,eAAU,GAAV,UAAU,CAAqB;QACnB,mBAAc,GAAd,cAAc,CAAS;IAEvF,CAAC;IAED;;;;;OAKG;IACG,iBAAiB,CAAC,OAA6B,EAAE,OAA2B,EAAE,QAA+B;;YAC/G,IAAG,IAAI,CAAC,cAAc,EAAE;gBACpB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,EAAE,uCAAiB,CAAC,CAAC;aAC3F;YAED,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;CAEJ,CAAA;AArBY,8BAA8B;IAH1C,IAAA,YAAG,EAAC,iCAAwB,CAAC,uBAAuB,CAAC;IACrD,IAAA,qBAAY,EAAC,uCAAiB,CAAC;IAC/B,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,IAAA,iBAAM,EAAC,iCAAiC,CAAC,CAAA;;GAHrC,8BAA8B,CAqB1C;AArBY,wEAA8B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UrlUtils = void 0;
|
|
4
|
+
const url_1 = require("url");
|
|
5
|
+
class UrlUtils {
|
|
6
|
+
static appendLocationHeaderToUrl(url, locationHeader) {
|
|
7
|
+
if (locationHeader.startsWith("/")) {
|
|
8
|
+
url.pathname = locationHeader;
|
|
9
|
+
return url;
|
|
10
|
+
}
|
|
11
|
+
return new url_1.URL(locationHeader);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.UrlUtils = UrlUtils;
|
|
15
|
+
//# sourceMappingURL=url.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.utils.js","sourceRoot":"","sources":["../../../../src/utils/url.utils.ts"],"names":[],"mappings":";;;AAAA,6BAA0B;AAE1B,MAAa,QAAQ;IACjB,MAAM,CAAC,yBAAyB,CAAC,GAAQ,EAAE,cAAsB;QAC7D,IAAG,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YAC/B,GAAG,CAAC,QAAQ,GAAG,cAAc,CAAC;YAC9B,OAAO,GAAG,CAAC;SACd;QAED,OAAO,IAAI,SAAG,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;CACJ;AATD,4BASC"}
|
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./math.utils"), exports);
|
|
18
|
+
__exportStar(require("./url.utils"), exports);
|
|
18
19
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/utils/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/utils/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,8CAA4B"}
|
|
@@ -26,6 +26,7 @@ import { assign } from "lodash";
|
|
|
26
26
|
import { ServiceDefinitionTagEnum, tag } from "@pristine-ts/common";
|
|
27
27
|
import { MathUtils } from "../utils/math.utils";
|
|
28
28
|
import { HttpClientResponseRedirectError } from "../errors/http-client-response-redirect.error";
|
|
29
|
+
import { UrlUtils } from "../utils/url.utils";
|
|
29
30
|
/**
|
|
30
31
|
* This service is an http client for any http request you need to make outside of Pristine.
|
|
31
32
|
*/
|
|
@@ -178,9 +179,7 @@ let HttpClient = class HttpClient {
|
|
|
178
179
|
}
|
|
179
180
|
const updatedRequest = request;
|
|
180
181
|
// Updated the URL by using the 'location' header returned by the response.
|
|
181
|
-
|
|
182
|
-
url.pathname = response.headers.location;
|
|
183
|
-
updatedRequest.url = url.toString();
|
|
182
|
+
updatedRequest.url = UrlUtils.appendLocationHeaderToUrl(new URL(request.url), response.headers.location).toString();
|
|
184
183
|
const updatedRedirectCount = ++currentRedirectCount;
|
|
185
184
|
// Retry the request using an exponential backoff with jitter.
|
|
186
185
|
updatedResponse = yield this.httpWrapper.executeRequest(updatedRequest);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.client.js","sourceRoot":"","sources":["../../../../src/clients/http.client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE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,4BAA4B,CAAC,CAAA;;GArBpE,UAAU,CA+LtB;SA/LY,UAAU"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HttpModuleKeyname } from "./http.module.keyname";
|
|
2
2
|
import { LoggingModule } from "@pristine-ts/logging";
|
|
3
|
+
import { BooleanResolver, EnvironmentVariableResolver } from "@pristine-ts/configuration";
|
|
3
4
|
export * from "./clients/clients";
|
|
4
5
|
export * from "./enums/enums";
|
|
5
6
|
export * from "./errors/errors";
|
|
@@ -11,6 +12,15 @@ export * from "./wrappers/wrappers";
|
|
|
11
12
|
export const HttpModule = {
|
|
12
13
|
keyname: HttpModuleKeyname,
|
|
13
14
|
importModules: [LoggingModule],
|
|
14
|
-
configurationDefinitions: [
|
|
15
|
+
configurationDefinitions: [
|
|
16
|
+
{
|
|
17
|
+
parameterName: "pristine.http.logging-enabled",
|
|
18
|
+
defaultValue: true,
|
|
19
|
+
isRequired: false,
|
|
20
|
+
defaultResolvers: [
|
|
21
|
+
new BooleanResolver(new EnvironmentVariableResolver("PRISTINE_HTTP_LOGGING")),
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
],
|
|
15
25
|
};
|
|
16
26
|
//# sourceMappingURL=http.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.module.js","sourceRoot":"","sources":["../../../src/http.module.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"http.module.js","sourceRoot":"","sources":["../../../src/http.module.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAC,eAAe,EAAE,2BAA2B,EAAC,MAAM,4BAA4B,CAAC;AAExF,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AAEpC,MAAM,CAAC,MAAM,UAAU,GAAoB;IACvC,OAAO,EAAE,iBAAiB;IAC1B,aAAa,EAAE,CAAC,aAAa,CAAC;IAC9B,wBAAwB,EAAE;QACtB;YACI,aAAa,EAAE,+BAA+B;YAC9C,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,eAAe,CAAC,IAAI,2BAA2B,CAAC,uBAAuB,CAAC,CAAC;aAChF;SACJ;KACJ;CACJ,CAAA"}
|
|
@@ -28,8 +28,9 @@ import { HttpModuleKeyname } from "../http.module.keyname";
|
|
|
28
28
|
* It is module scoped to the http module so that it is only registered if the http module is imported.
|
|
29
29
|
*/
|
|
30
30
|
let HttpErrorResponseLoggingInterceptor = class HttpErrorResponseLoggingInterceptor {
|
|
31
|
-
constructor(logHandler) {
|
|
31
|
+
constructor(logHandler, loggingEnabled) {
|
|
32
32
|
this.logHandler = logHandler;
|
|
33
|
+
this.loggingEnabled = loggingEnabled;
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* This method intercepts an incoming http response that has an error and logs it.
|
|
@@ -39,7 +40,9 @@ let HttpErrorResponseLoggingInterceptor = class HttpErrorResponseLoggingIntercep
|
|
|
39
40
|
*/
|
|
40
41
|
interceptErrorResponse(request, options, response) {
|
|
41
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
this.
|
|
43
|
+
if (this.loggingEnabled) {
|
|
44
|
+
this.logHandler.error("Receiving http response that has an error", { response, options }, HttpModuleKeyname);
|
|
45
|
+
}
|
|
43
46
|
return response;
|
|
44
47
|
});
|
|
45
48
|
}
|
|
@@ -49,7 +52,8 @@ HttpErrorResponseLoggingInterceptor = __decorate([
|
|
|
49
52
|
moduleScoped(HttpModuleKeyname),
|
|
50
53
|
injectable(),
|
|
51
54
|
__param(0, inject("LogHandlerInterface")),
|
|
52
|
-
|
|
55
|
+
__param(1, inject("%pristine.http.logging-enabled%")),
|
|
56
|
+
__metadata("design:paramtypes", [Object, Boolean])
|
|
53
57
|
], HttpErrorResponseLoggingInterceptor);
|
|
54
58
|
export { HttpErrorResponseLoggingInterceptor };
|
|
55
59
|
//# sourceMappingURL=http-error-response-logging.interceptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-error-response-logging.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/http-error-response-logging.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAKlF,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AAGzD;;;;GAIG;AAII,IAAM,mCAAmC,GAAzC,MAAM,mCAAmC;IAC5C,
|
|
1
|
+
{"version":3,"file":"http-error-response-logging.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/http-error-response-logging.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAKlF,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AAGzD;;;;GAIG;AAII,IAAM,mCAAmC,GAAzC,MAAM,mCAAmC;IAC5C,YACoD,UAA+B,EACnB,cAAuB;QADnC,eAAU,GAAV,UAAU,CAAqB;QACnB,mBAAc,GAAd,cAAc,CAAS;IAEvF,CAAC;IAED;;;;;OAKG;IACG,sBAAsB,CAAC,OAA6B,EAAE,OAA2B,EAAE,QAA+B;;YACpH,IAAG,IAAI,CAAC,cAAc,EAAE;gBACpB,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,2CAA2C,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,EAAE,iBAAiB,CAAC,CAAC;aAC9G;YAED,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;CAEJ,CAAA;AArBY,mCAAmC;IAH/C,GAAG,CAAC,wBAAwB,CAAC,4BAA4B,CAAC;IAC1D,YAAY,CAAC,iBAAiB,CAAC;IAC/B,UAAU,EAAE;IAGJ,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,MAAM,CAAC,iCAAiC,CAAC,CAAA;;GAHrC,mCAAmC,CAqB/C;SArBY,mCAAmC"}
|
|
@@ -28,8 +28,9 @@ import { HttpModuleKeyname } from "../http.module.keyname";
|
|
|
28
28
|
* It is module scoped to the http module so that it is only registered if the http module is imported.
|
|
29
29
|
*/
|
|
30
30
|
let HttpRequestLoggingInterceptor = class HttpRequestLoggingInterceptor {
|
|
31
|
-
constructor(logHandler) {
|
|
31
|
+
constructor(logHandler, loggingEnabled) {
|
|
32
32
|
this.logHandler = logHandler;
|
|
33
|
+
this.loggingEnabled = loggingEnabled;
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* This method intercepts an outgoing http request and logs it.
|
|
@@ -38,7 +39,9 @@ let HttpRequestLoggingInterceptor = class HttpRequestLoggingInterceptor {
|
|
|
38
39
|
*/
|
|
39
40
|
interceptRequest(request, options) {
|
|
40
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
this.
|
|
42
|
+
if (this.loggingEnabled) {
|
|
43
|
+
this.logHandler.info("Outgoing http request", { request, options }, HttpModuleKeyname);
|
|
44
|
+
}
|
|
42
45
|
return request;
|
|
43
46
|
});
|
|
44
47
|
}
|
|
@@ -48,7 +51,8 @@ HttpRequestLoggingInterceptor = __decorate([
|
|
|
48
51
|
moduleScoped(HttpModuleKeyname),
|
|
49
52
|
injectable(),
|
|
50
53
|
__param(0, inject("LogHandlerInterface")),
|
|
51
|
-
|
|
54
|
+
__param(1, inject("%pristine.http.logging-enabled%")),
|
|
55
|
+
__metadata("design:paramtypes", [Object, Boolean])
|
|
52
56
|
], HttpRequestLoggingInterceptor);
|
|
53
57
|
export { HttpRequestLoggingInterceptor };
|
|
54
58
|
//# sourceMappingURL=http-request-logging.interceptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-request-logging.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/http-request-logging.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAIlF,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AAEzD;;;;GAIG;AAII,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IACtC,
|
|
1
|
+
{"version":3,"file":"http-request-logging.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/http-request-logging.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAIlF,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AAEzD;;;;GAIG;AAII,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IACtC,YACoD,UAA+B,EACnB,cAAuB;QADnC,eAAU,GAAV,UAAU,CAAqB;QACnB,mBAAc,GAAd,cAAc,CAAS;IAEvF,CAAC;IAED;;;;OAIG;IACG,gBAAgB,CAAC,OAA6B,EAAE,OAA2B;;YAC7E,IAAG,IAAI,CAAC,cAAc,EAAE;gBACpB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAC,OAAO,EAAE,OAAO,EAAC,EAAE,iBAAiB,CAAC,CAAC;aACxF;YAED,OAAO,OAAO,CAAC;QACnB,CAAC;KAAA;CACJ,CAAA;AAnBY,6BAA6B;IAHzC,GAAG,CAAC,wBAAwB,CAAC,sBAAsB,CAAC;IACpD,YAAY,CAAC,iBAAiB,CAAC;IAC/B,UAAU,EAAE;IAGJ,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,MAAM,CAAC,iCAAiC,CAAC,CAAA;;GAHrC,6BAA6B,CAmBzC;SAnBY,6BAA6B"}
|
|
@@ -28,8 +28,9 @@ import { HttpModuleKeyname } from "../http.module.keyname";
|
|
|
28
28
|
* It is module scoped to the http module so that it is only registered if the http module is imported.
|
|
29
29
|
*/
|
|
30
30
|
let HttpResponseLoggingInterceptor = class HttpResponseLoggingInterceptor {
|
|
31
|
-
constructor(logHandler) {
|
|
31
|
+
constructor(logHandler, loggingEnabled) {
|
|
32
32
|
this.logHandler = logHandler;
|
|
33
|
+
this.loggingEnabled = loggingEnabled;
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* This method intercepts an incoming http response and logs it.
|
|
@@ -39,7 +40,9 @@ let HttpResponseLoggingInterceptor = class HttpResponseLoggingInterceptor {
|
|
|
39
40
|
*/
|
|
40
41
|
interceptResponse(request, options, response) {
|
|
41
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
this.
|
|
43
|
+
if (this.loggingEnabled) {
|
|
44
|
+
this.logHandler.info("Receiving http response", { response, options }, HttpModuleKeyname);
|
|
45
|
+
}
|
|
43
46
|
return response;
|
|
44
47
|
});
|
|
45
48
|
}
|
|
@@ -49,7 +52,8 @@ HttpResponseLoggingInterceptor = __decorate([
|
|
|
49
52
|
moduleScoped(HttpModuleKeyname),
|
|
50
53
|
injectable(),
|
|
51
54
|
__param(0, inject("LogHandlerInterface")),
|
|
52
|
-
|
|
55
|
+
__param(1, inject("%pristine.http.logging-enabled%")),
|
|
56
|
+
__metadata("design:paramtypes", [Object, Boolean])
|
|
53
57
|
], HttpResponseLoggingInterceptor);
|
|
54
58
|
export { HttpResponseLoggingInterceptor };
|
|
55
59
|
//# sourceMappingURL=http-response-logging.interceptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-response-logging.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/http-response-logging.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAMlF,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AAEzD;;;;GAIG;AAII,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IACvC,
|
|
1
|
+
{"version":3,"file":"http-response-logging.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/http-response-logging.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAMlF,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AAEzD;;;;GAIG;AAII,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IACvC,YACoD,UAA+B,EACnB,cAAuB;QADnC,eAAU,GAAV,UAAU,CAAqB;QACnB,mBAAc,GAAd,cAAc,CAAS;IAEvF,CAAC;IAED;;;;;OAKG;IACG,iBAAiB,CAAC,OAA6B,EAAE,OAA2B,EAAE,QAA+B;;YAC/G,IAAG,IAAI,CAAC,cAAc,EAAE;gBACpB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,EAAE,iBAAiB,CAAC,CAAC;aAC3F;YAED,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;CAEJ,CAAA;AArBY,8BAA8B;IAH1C,GAAG,CAAC,wBAAwB,CAAC,uBAAuB,CAAC;IACrD,YAAY,CAAC,iBAAiB,CAAC;IAC/B,UAAU,EAAE;IAGJ,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,MAAM,CAAC,iCAAiC,CAAC,CAAA;;GAHrC,8BAA8B,CAqB1C;SArBY,8BAA8B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { URL } from 'url';
|
|
2
|
+
export class UrlUtils {
|
|
3
|
+
static appendLocationHeaderToUrl(url, locationHeader) {
|
|
4
|
+
if (locationHeader.startsWith("/")) {
|
|
5
|
+
url.pathname = locationHeader;
|
|
6
|
+
return url;
|
|
7
|
+
}
|
|
8
|
+
return new URL(locationHeader);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=url.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.utils.js","sourceRoot":"","sources":["../../../../src/utils/url.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,OAAO,QAAQ;IACjB,MAAM,CAAC,yBAAyB,CAAC,GAAQ,EAAE,cAAsB;QAC7D,IAAG,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YAC/B,GAAG,CAAC,QAAQ,GAAG,cAAc,CAAC;YAC9B,OAAO,GAAG,CAAC;SACd;QAED,OAAO,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
|
@@ -10,7 +10,8 @@ import { HttpErrorResponseInterceptorInterface } from "../interfaces/http-error-
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class HttpErrorResponseLoggingInterceptor implements HttpErrorResponseInterceptorInterface {
|
|
12
12
|
private readonly logHandler;
|
|
13
|
-
|
|
13
|
+
private readonly loggingEnabled;
|
|
14
|
+
constructor(logHandler: LogHandlerInterface, loggingEnabled: boolean);
|
|
14
15
|
/**
|
|
15
16
|
* This method intercepts an incoming http response that has an error and logs it.
|
|
16
17
|
* @param request
|
|
@@ -9,7 +9,8 @@ import { LogHandlerInterface } from "@pristine-ts/logging";
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class HttpRequestLoggingInterceptor implements HttpRequestInterceptorInterface {
|
|
11
11
|
private readonly logHandler;
|
|
12
|
-
|
|
12
|
+
private readonly loggingEnabled;
|
|
13
|
+
constructor(logHandler: LogHandlerInterface, loggingEnabled: boolean);
|
|
13
14
|
/**
|
|
14
15
|
* This method intercepts an outgoing http request and logs it.
|
|
15
16
|
* @param request
|
|
@@ -10,7 +10,8 @@ import { HttpResponseInterface } from "../interfaces/http-response.interface";
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class HttpResponseLoggingInterceptor implements HttpResponseInterceptorInterface {
|
|
12
12
|
private readonly logHandler;
|
|
13
|
-
|
|
13
|
+
private readonly loggingEnabled;
|
|
14
|
+
constructor(logHandler: LogHandlerInterface, loggingEnabled: boolean);
|
|
14
15
|
/**
|
|
15
16
|
* This method intercepts an incoming http response and logs it.
|
|
16
17
|
* @param request
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pristine-ts/http",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.233",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "dist/lib/esm/http.module.js",
|
|
6
6
|
"main": "dist/lib/cjs/http.module.js",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@pristine-ts/common": "^0.0.
|
|
19
|
-
"@pristine-ts/logging": "^0.0.
|
|
18
|
+
"@pristine-ts/common": "^0.0.233",
|
|
19
|
+
"@pristine-ts/logging": "^0.0.233",
|
|
20
20
|
"lodash": "^4.17.21"
|
|
21
21
|
},
|
|
22
22
|
"author": "",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"src/*.{js,ts}"
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "8964b912280e65996ee81f8f9d1530f0522ac607"
|
|
62
62
|
}
|