@pristine-ts/networking 0.0.192 → 0.0.193
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/interceptors/default-content-type-response-header.interceptor.js +75 -0
- package/dist/lib/cjs/interceptors/default-content-type-response-header.interceptor.js.map +1 -0
- package/dist/lib/cjs/interceptors/interceptors.js +1 -0
- package/dist/lib/cjs/interceptors/interceptors.js.map +1 -1
- package/dist/lib/cjs/interceptors/request-body-converter.interceptor.js +15 -1
- package/dist/lib/cjs/interceptors/request-body-converter.interceptor.js.map +1 -1
- package/dist/lib/cjs/interceptors/response-headers.interceptor.js +6 -0
- package/dist/lib/cjs/interceptors/response-headers.interceptor.js.map +1 -1
- package/dist/lib/cjs/networking.module.js +26 -1
- package/dist/lib/cjs/networking.module.js.map +1 -1
- package/dist/lib/esm/interceptors/default-content-type-response-header.interceptor.js +72 -0
- package/dist/lib/esm/interceptors/default-content-type-response-header.interceptor.js.map +1 -0
- package/dist/lib/esm/interceptors/interceptors.js +1 -0
- package/dist/lib/esm/interceptors/interceptors.js.map +1 -1
- package/dist/lib/esm/interceptors/request-body-converter.interceptor.js +15 -1
- package/dist/lib/esm/interceptors/request-body-converter.interceptor.js.map +1 -1
- package/dist/lib/esm/interceptors/response-headers.interceptor.js +6 -0
- package/dist/lib/esm/interceptors/response-headers.interceptor.js.map +1 -1
- package/dist/lib/esm/networking.module.js +26 -1
- package/dist/lib/esm/networking.module.js.map +1 -1
- package/dist/types/interceptors/default-content-type-response-header.interceptor.d.ts +28 -0
- package/dist/types/interceptors/interceptors.d.ts +1 -0
- package/dist/types/interceptors/request-body-converter.interceptor.d.ts +14 -0
- package/dist/types/interceptors/response-headers.interceptor.d.ts +6 -0
- package/package.json +6 -6
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.DefaultContentTypeResponseHeaderInterceptor = void 0;
|
|
25
|
+
const common_1 = require("@pristine-ts/common");
|
|
26
|
+
const networking_module_keyname_1 = require("../networking.module.keyname");
|
|
27
|
+
const tsyringe_1 = require("tsyringe");
|
|
28
|
+
/**
|
|
29
|
+
* The Default ContentType Response Header Interceptor intercepts the response of the router and adds the default content-type header to the response.
|
|
30
|
+
* It is tagged as a RequestInterceptor so it can be automatically injected with the all the other RequestInterceptor.
|
|
31
|
+
*/
|
|
32
|
+
let DefaultContentTypeResponseHeaderInterceptor = class DefaultContentTypeResponseHeaderInterceptor {
|
|
33
|
+
/**
|
|
34
|
+
* The Default ContentType Response Header Interceptor intercepts the response of the router and adds the default content-type header to the response.
|
|
35
|
+
* It is tagged as a RequestInterceptor so it can be automatically injected with the all the other RequestInterceptor.
|
|
36
|
+
* @param defaultContentTypeResponseHeader The default Content-Type response header to set on responses that do not already have Content-Types.
|
|
37
|
+
* @param isActive Whether or not this interceptor is active.
|
|
38
|
+
* @param logHandler The log handler to output logs.
|
|
39
|
+
*/
|
|
40
|
+
constructor(defaultContentTypeResponseHeader, isActive, logHandler) {
|
|
41
|
+
this.defaultContentTypeResponseHeader = defaultContentTypeResponseHeader;
|
|
42
|
+
this.isActive = isActive;
|
|
43
|
+
this.logHandler = logHandler;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Intercepts the response from the router and adds the Content-Type header to it if it's not already there, with the default provided.
|
|
47
|
+
* @param response The response to intercept.
|
|
48
|
+
* @param request The request that triggered this response.
|
|
49
|
+
* @param methodNode The methode node.
|
|
50
|
+
*/
|
|
51
|
+
interceptResponse(response, request, methodNode) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
if (this.isActive === false) {
|
|
54
|
+
return response;
|
|
55
|
+
}
|
|
56
|
+
if (response.hasHeader("content-type")) {
|
|
57
|
+
return response;
|
|
58
|
+
}
|
|
59
|
+
response.setHeader("content-type", this.defaultContentTypeResponseHeader);
|
|
60
|
+
this.logHandler.debug("Set the default content type response header.", { response });
|
|
61
|
+
return response;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
DefaultContentTypeResponseHeaderInterceptor = __decorate([
|
|
66
|
+
common_1.tag(common_1.ServiceDefinitionTagEnum.RequestInterceptor),
|
|
67
|
+
common_1.moduleScoped(networking_module_keyname_1.NetworkingModuleKeyname),
|
|
68
|
+
tsyringe_1.injectable(),
|
|
69
|
+
__param(0, tsyringe_1.inject(`%${networking_module_keyname_1.NetworkingModuleKeyname}.defaultContentTypeResponseHeader%`)),
|
|
70
|
+
__param(1, tsyringe_1.inject(`%${networking_module_keyname_1.NetworkingModuleKeyname}.defaultContentTypeResponseHeader.isActive%`)),
|
|
71
|
+
__param(2, tsyringe_1.inject("LogHandlerInterface")),
|
|
72
|
+
__metadata("design:paramtypes", [String, Boolean, Object])
|
|
73
|
+
], DefaultContentTypeResponseHeaderInterceptor);
|
|
74
|
+
exports.DefaultContentTypeResponseHeaderInterceptor = DefaultContentTypeResponseHeaderInterceptor;
|
|
75
|
+
//# sourceMappingURL=default-content-type-response-header.interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-content-type-response-header.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/default-content-type-response-header.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAmG;AACnG,4EAAqE;AAGrE,uCAA4C;AAG5C;;;GAGG;AAIH,IAAa,2CAA2C,GAAxD,MAAa,2CAA2C;IAEpD;;;;;;OAMG;IACH,YAAsG,gCAAwC,EAC/B,QAAiB,EACpE,UAA+B;QAFW,qCAAgC,GAAhC,gCAAgC,CAAQ;QAC/B,aAAQ,GAAR,QAAQ,CAAS;QACpE,eAAU,GAAV,UAAU,CAAqB;IAAE,CAAC;IAE9F;;;;;OAKG;IACG,iBAAiB,CAAC,QAAkB,EAAE,OAAgB,EAAE,UAA6B;;YACvF,IAAG,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE;gBACxB,OAAO,QAAQ,CAAC;aACnB;YAED,IAAG,QAAQ,CAAC,SAAS,CAAC,cAAc,CAAC,EAAC;gBAClC,OAAO,QAAQ,CAAC;aACnB;YAED,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,gCAAgC,CAAC,CAAC;YAC1E,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,+CAA+C,EAAE,EAAC,QAAQ,EAAC,CAAC,CAAA;YAElF,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;CACJ,CAAA;AAjCY,2CAA2C;IAHvD,YAAG,CAAC,iCAAwB,CAAC,kBAAkB,CAAC;IAChD,qBAAY,CAAC,mDAAuB,CAAC;IACrC,qBAAU,EAAE;IAUI,WAAA,iBAAM,CAAC,IAAI,mDAAuB,oCAAoC,CAAC,CAAA;IACvE,WAAA,iBAAM,CAAC,IAAI,mDAAuB,6CAA6C,CAAC,CAAA;IAChF,WAAA,iBAAM,CAAC,qBAAqB,CAAC,CAAA;;GAXjC,2CAA2C,CAiCvD;AAjCY,kGAA2C"}
|
|
@@ -10,6 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./default-content-type-response-header.interceptor"), exports);
|
|
13
14
|
__exportStar(require("./request-body-converter.interceptor"), exports);
|
|
14
15
|
__exportStar(require("./response-headers.interceptor"), exports);
|
|
15
16
|
//# sourceMappingURL=interceptors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interceptors.js","sourceRoot":"","sources":["../../../../src/interceptors/interceptors.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uEAAqD;AACrD,iEAA+C"}
|
|
1
|
+
{"version":3,"file":"interceptors.js","sourceRoot":"","sources":["../../../../src/interceptors/interceptors.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qFAAmE;AACnE,uEAAqD;AACrD,iEAA+C"}
|
|
@@ -26,11 +26,25 @@ const tsyringe_1 = require("tsyringe");
|
|
|
26
26
|
const common_1 = require("@pristine-ts/common");
|
|
27
27
|
const networking_module_keyname_1 = require("../networking.module.keyname");
|
|
28
28
|
const invalid_body_http_error_1 = require("../errors/invalid-body.http-error");
|
|
29
|
+
/**
|
|
30
|
+
* The Request Body Converter Interceptor intercepts the request and parses the body based on the Content-tTpe header.
|
|
31
|
+
* It is tagged as a RequestInterceptor so it can be automatically injected with the all the other RequestInterceptor.
|
|
32
|
+
*/
|
|
29
33
|
let RequestBodyConverterInterceptor = class RequestBodyConverterInterceptor {
|
|
34
|
+
/**
|
|
35
|
+
* The Request Body Converter Interceptor intercepts the request and parses the body based on the Content-Type header.
|
|
36
|
+
* It is tagged as a RequestInterceptor so it can be automatically injected with the all the other RequestInterceptor.
|
|
37
|
+
* @param isActive Whether or not this interceptor is active.
|
|
38
|
+
* @param logHandler The log handler to output logs.
|
|
39
|
+
*/
|
|
30
40
|
constructor(isActive, logHandler) {
|
|
31
41
|
this.isActive = isActive;
|
|
32
42
|
this.logHandler = logHandler;
|
|
33
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Intercepts the request and parses the body based on it's Content-Type header.
|
|
46
|
+
* @param request The request to intercept.
|
|
47
|
+
*/
|
|
34
48
|
interceptRequest(request) {
|
|
35
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
50
|
if (this.isActive === false) {
|
|
@@ -78,7 +92,7 @@ RequestBodyConverterInterceptor = __decorate([
|
|
|
78
92
|
common_1.tag(common_1.ServiceDefinitionTagEnum.RequestInterceptor),
|
|
79
93
|
common_1.moduleScoped(networking_module_keyname_1.NetworkingModuleKeyname),
|
|
80
94
|
tsyringe_1.injectable(),
|
|
81
|
-
__param(0, tsyringe_1.inject("%" + networking_module_keyname_1.NetworkingModuleKeyname + ".
|
|
95
|
+
__param(0, tsyringe_1.inject("%" + networking_module_keyname_1.NetworkingModuleKeyname + ".requestBodyConverter.isActive%")),
|
|
82
96
|
__param(1, tsyringe_1.inject("LogHandlerInterface")),
|
|
83
97
|
__metadata("design:paramtypes", [Boolean, Object])
|
|
84
98
|
], RequestBodyConverterInterceptor);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-body-converter.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/request-body-converter.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAE5C,gDAAyF;AACzF,4EAAqE;AAErE,+EAAuE;
|
|
1
|
+
{"version":3,"file":"request-body-converter.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/request-body-converter.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAE5C,gDAAyF;AACzF,4EAAqE;AAErE,+EAAuE;AAEvE;;;GAGG;AAIH,IAAa,+BAA+B,GAA5C,MAAa,+BAA+B;IAExC;;;;;OAKG;IACH,YAAwG,QAAiB,EAC7D,UAA+B;QADa,aAAQ,GAAR,QAAQ,CAAS;QAC7D,eAAU,GAAV,UAAU,CAAqB;IAC3F,CAAC;IAED;;;OAGG;IACG,gBAAgB,CAAC,OAAgB;;YACnC,IAAG,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE;gBACxB,OAAO,OAAO,CAAC;aAClB;YAED,IAAG,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,KAAK,EAAE;gBAC5C,OAAO,OAAO,CAAC;aAClB;YAED,MAAM,WAAW,GAAW,OAAO,CAAC,SAAS,CAAC,cAAc,CAAW,CAAC;YAExE,QAAQ,WAAW,CAAC,WAAW,EAAE,EAAE;gBAC/B,KAAK,kBAAkB;oBAGnB,QAAQ,OAAO,OAAO,CAAC,IAAI,EAAE;wBACzB,KAAK,WAAW;4BACZ,OAAO,OAAO,CAAC;wBACnB,KAAK,QAAQ;4BACT,IAAG,OAAO,CAAC,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE;gCAClC,MAAM,YAAY,GAAG,kHAAkH,CAAC;gCACxI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;gCAEpC,MAAM,IAAI,8CAAoB,CAAC,YAAY,CAAC,CAAC;6BAChD;4BACD,OAAO,OAAO,CAAC;wBAEnB,KAAK,QAAQ;4BACT,IAAI;gCACA,IAAG,OAAO,CAAC,IAAI,EAAE;oCACb,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;iCAC3C;6BACJ;4BACD,OAAO,CAAC,EAAE;gCACN,MAAM,YAAY,GAAG,kIAAkI,CAAC;gCACxJ,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;gCAEpC,MAAM,IAAI,8CAAoB,CAAC,YAAY,CAAC,CAAC;6BAChD;4BACD,MAAM;wBAEV;4BACI,MAAM,YAAY,GAAG,iGAAiG,CAAC;4BACvH,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;4BAEpC,MAAM,IAAI,8CAAoB,CAAC,YAAY,CAAC,CAAC;qBACpD;aAGR;YAED,OAAO,OAAO,CAAC;QACnB,CAAC;KAAA;CAEJ,CAAA;AAtEY,+BAA+B;IAH3C,YAAG,CAAC,iCAAwB,CAAC,kBAAkB,CAAC;IAChD,qBAAY,CAAC,mDAAuB,CAAC;IACrC,qBAAU,EAAE;IASI,WAAA,iBAAM,CAAC,GAAG,GAAG,mDAAuB,GAAG,iCAAiC,CAAC,CAAA;IACzE,WAAA,iBAAM,CAAC,qBAAqB,CAAC,CAAA;;GATjC,+BAA+B,CAsE3C;AAtEY,0EAA+B"}
|
|
@@ -24,6 +24,12 @@ const tsyringe_1 = require("tsyringe");
|
|
|
24
24
|
* It is tagged as a RequestInterceptor so it can be automatically injected with the all the other RequestInterceptor.
|
|
25
25
|
*/
|
|
26
26
|
let ResponseHeadersInterceptor = class ResponseHeadersInterceptor {
|
|
27
|
+
/**
|
|
28
|
+
* Intercepts the response from the router and adds the headers specified by the response header decorator.
|
|
29
|
+
* @param response The response to intercept.
|
|
30
|
+
* @param request The request that triggered this response.
|
|
31
|
+
* @param methodNode The methode node.
|
|
32
|
+
*/
|
|
27
33
|
interceptResponse(response, request, methodNode) {
|
|
28
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
35
|
if (methodNode && methodNode.route.context && methodNode.route.context.hasOwnProperty("responseHeaders")) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-headers.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/response-headers.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,gDAAmG;AACnG,4EAAqE;AAGrE,uCAAoC;AACpC;;;GAGG;AAIH,IAAa,0BAA0B,GAAvC,MAAa,0BAA0B;
|
|
1
|
+
{"version":3,"file":"response-headers.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/response-headers.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,gDAAmG;AACnG,4EAAqE;AAGrE,uCAAoC;AACpC;;;GAGG;AAIH,IAAa,0BAA0B,GAAvC,MAAa,0BAA0B;IAEnC;;;;;OAKG;IACG,iBAAiB,CAAC,QAAkB,EAAE,OAAgB,EAAE,UAA6B;;YACvF,IAAG,UAAU,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAC;gBACpG,QAAQ,CAAC,UAAU,iCAAK,QAAQ,CAAC,OAAO,GAAK,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;aAC3F;YAED,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;CACJ,CAAA;AAfY,0BAA0B;IAHtC,YAAG,CAAC,iCAAwB,CAAC,kBAAkB,CAAC;IAChD,qBAAY,CAAC,mDAAuB,CAAC;IACrC,qBAAU,EAAE;GACA,0BAA0B,CAetC;AAfY,gEAA0B"}
|
|
@@ -33,13 +33,38 @@ exports.NetworkingModule = {
|
|
|
33
33
|
telemetry_1.TelemetryModule,
|
|
34
34
|
],
|
|
35
35
|
configurationDefinitions: [
|
|
36
|
+
/**
|
|
37
|
+
* Whether or not the request body converter interceptor is active.
|
|
38
|
+
*/
|
|
36
39
|
{
|
|
37
|
-
parameterName: networking_module_keyname_1.NetworkingModuleKeyname + ".
|
|
40
|
+
parameterName: networking_module_keyname_1.NetworkingModuleKeyname + ".requestBodyConverter.isActive",
|
|
38
41
|
isRequired: false,
|
|
39
42
|
defaultValue: true,
|
|
40
43
|
defaultResolvers: [
|
|
41
44
|
new configuration_1.BooleanResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_NETWORKING_REQUEST_BODY_CONVERTER_IS_ACTIVE")),
|
|
42
45
|
],
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Whether or not the default content type response header interceptor is active.
|
|
49
|
+
*/
|
|
50
|
+
{
|
|
51
|
+
parameterName: networking_module_keyname_1.NetworkingModuleKeyname + ".defaultContentTypeResponseHeader.isActive",
|
|
52
|
+
isRequired: false,
|
|
53
|
+
defaultValue: true,
|
|
54
|
+
defaultResolvers: [
|
|
55
|
+
new configuration_1.BooleanResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_NETWORKING_DEFAULT_CONTENT_TYPE_RESPONSE_HEADER_IS_ACTIVE")),
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* The default Content-Type response header to set on responses that do not already have Content-Types.
|
|
60
|
+
*/
|
|
61
|
+
{
|
|
62
|
+
parameterName: networking_module_keyname_1.NetworkingModuleKeyname + ".defaultContentTypeResponseHeader",
|
|
63
|
+
isRequired: false,
|
|
64
|
+
defaultValue: "application/json",
|
|
65
|
+
defaultResolvers: [
|
|
66
|
+
new configuration_1.EnvironmentVariableResolver("PRISTINE_NETWORKING_DEFAULT_CONTENT_TYPE_RESPONSE_HEADER"),
|
|
67
|
+
],
|
|
43
68
|
}
|
|
44
69
|
],
|
|
45
70
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"networking.module.js","sourceRoot":"","sources":["../../../src/networking.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,2EAAoE;AACpE,oDAAqD;AACrD,sDAAuD;AACvD,8DAAwF;AAExF,0DAAwC;AACxC,kDAAgC;AAChC,sDAAoC;AACpC,8DAA4C;AAC5C,0DAAwC;AACxC,oDAAkC;AAClC,kDAAgC;AAChC,gDAA8B;AAC9B,wDAAsC;AACtC,gDAA8B;AAE9B,2CAAyB;AAEZ,QAAA,gBAAgB,GAAoB;IAC7C,OAAO,EAAE,mDAAuB;IAChC,aAAa,EAAE;QACX,yBAAc;QACd,2BAAe;KAClB;IACD,wBAAwB,EAAE;QACtB;YACI,aAAa,EAAE,mDAAuB,GAAG,
|
|
1
|
+
{"version":3,"file":"networking.module.js","sourceRoot":"","sources":["../../../src/networking.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,2EAAoE;AACpE,oDAAqD;AACrD,sDAAuD;AACvD,8DAAwF;AAExF,0DAAwC;AACxC,kDAAgC;AAChC,sDAAoC;AACpC,8DAA4C;AAC5C,0DAAwC;AACxC,oDAAkC;AAClC,kDAAgC;AAChC,gDAA8B;AAC9B,wDAAsC;AACtC,gDAA8B;AAE9B,2CAAyB;AAEZ,QAAA,gBAAgB,GAAoB;IAC7C,OAAO,EAAE,mDAAuB;IAChC,aAAa,EAAE;QACX,yBAAc;QACd,2BAAe;KAClB;IACD,wBAAwB,EAAE;QACtB;;WAEG;QACH;YACI,aAAa,EAAE,mDAAuB,GAAG,gCAAgC;YACzE,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,IAAI;YAClB,gBAAgB,EAAE;gBACd,IAAI,+BAAe,CAAC,IAAI,2CAA2B,CAAC,sDAAsD,CAAC,CAAC;aAC/G;SACJ;QAED;;WAEG;QACH;YACI,aAAa,EAAE,mDAAuB,GAAG,4CAA4C;YACrF,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,IAAI;YAClB,gBAAgB,EAAE;gBACd,IAAI,+BAAe,CAAC,IAAI,2CAA2B,CAAC,oEAAoE,CAAC,CAAC;aAC7H;SACJ;QAED;;WAEG;QACH;YACI,aAAa,EAAE,mDAAuB,GAAG,mCAAmC;YAC5E,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,kBAAkB;YAChC,gBAAgB,EAAE;gBACd,IAAI,2CAA2B,CAAC,0DAA0D,CAAC;aAC9F;SACJ;KACJ;CACJ,CAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
import { moduleScoped, ServiceDefinitionTagEnum, tag } from "@pristine-ts/common";
|
|
23
|
+
import { NetworkingModuleKeyname } from "../networking.module.keyname";
|
|
24
|
+
import { injectable, inject } from "tsyringe";
|
|
25
|
+
/**
|
|
26
|
+
* The Default ContentType Response Header Interceptor intercepts the response of the router and adds the default content-type header to the response.
|
|
27
|
+
* It is tagged as a RequestInterceptor so it can be automatically injected with the all the other RequestInterceptor.
|
|
28
|
+
*/
|
|
29
|
+
let DefaultContentTypeResponseHeaderInterceptor = class DefaultContentTypeResponseHeaderInterceptor {
|
|
30
|
+
/**
|
|
31
|
+
* The Default ContentType Response Header Interceptor intercepts the response of the router and adds the default content-type header to the response.
|
|
32
|
+
* It is tagged as a RequestInterceptor so it can be automatically injected with the all the other RequestInterceptor.
|
|
33
|
+
* @param defaultContentTypeResponseHeader The default Content-Type response header to set on responses that do not already have Content-Types.
|
|
34
|
+
* @param isActive Whether or not this interceptor is active.
|
|
35
|
+
* @param logHandler The log handler to output logs.
|
|
36
|
+
*/
|
|
37
|
+
constructor(defaultContentTypeResponseHeader, isActive, logHandler) {
|
|
38
|
+
this.defaultContentTypeResponseHeader = defaultContentTypeResponseHeader;
|
|
39
|
+
this.isActive = isActive;
|
|
40
|
+
this.logHandler = logHandler;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Intercepts the response from the router and adds the Content-Type header to it if it's not already there, with the default provided.
|
|
44
|
+
* @param response The response to intercept.
|
|
45
|
+
* @param request The request that triggered this response.
|
|
46
|
+
* @param methodNode The methode node.
|
|
47
|
+
*/
|
|
48
|
+
interceptResponse(response, request, methodNode) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
if (this.isActive === false) {
|
|
51
|
+
return response;
|
|
52
|
+
}
|
|
53
|
+
if (response.hasHeader("content-type")) {
|
|
54
|
+
return response;
|
|
55
|
+
}
|
|
56
|
+
response.setHeader("content-type", this.defaultContentTypeResponseHeader);
|
|
57
|
+
this.logHandler.debug("Set the default content type response header.", { response });
|
|
58
|
+
return response;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
DefaultContentTypeResponseHeaderInterceptor = __decorate([
|
|
63
|
+
tag(ServiceDefinitionTagEnum.RequestInterceptor),
|
|
64
|
+
moduleScoped(NetworkingModuleKeyname),
|
|
65
|
+
injectable(),
|
|
66
|
+
__param(0, inject(`%${NetworkingModuleKeyname}.defaultContentTypeResponseHeader%`)),
|
|
67
|
+
__param(1, inject(`%${NetworkingModuleKeyname}.defaultContentTypeResponseHeader.isActive%`)),
|
|
68
|
+
__param(2, inject("LogHandlerInterface")),
|
|
69
|
+
__metadata("design:paramtypes", [String, Boolean, Object])
|
|
70
|
+
], DefaultContentTypeResponseHeaderInterceptor);
|
|
71
|
+
export { DefaultContentTypeResponseHeaderInterceptor };
|
|
72
|
+
//# sourceMappingURL=default-content-type-response-header.interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-content-type-response-header.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/default-content-type-response-header.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,YAAY,EAAqB,wBAAwB,EAAE,GAAG,EAAC,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AAGrE,OAAO,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAG5C;;;GAGG;AAIH,IAAa,2CAA2C,GAAxD,MAAa,2CAA2C;IAEpD;;;;;;OAMG;IACH,YAAsG,gCAAwC,EAC/B,QAAiB,EACpE,UAA+B;QAFW,qCAAgC,GAAhC,gCAAgC,CAAQ;QAC/B,aAAQ,GAAR,QAAQ,CAAS;QACpE,eAAU,GAAV,UAAU,CAAqB;IAAE,CAAC;IAE9F;;;;;OAKG;IACG,iBAAiB,CAAC,QAAkB,EAAE,OAAgB,EAAE,UAA6B;;YACvF,IAAG,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE;gBACxB,OAAO,QAAQ,CAAC;aACnB;YAED,IAAG,QAAQ,CAAC,SAAS,CAAC,cAAc,CAAC,EAAC;gBAClC,OAAO,QAAQ,CAAC;aACnB;YAED,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,gCAAgC,CAAC,CAAC;YAC1E,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,+CAA+C,EAAE,EAAC,QAAQ,EAAC,CAAC,CAAA;YAElF,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;CACJ,CAAA;AAjCY,2CAA2C;IAHvD,GAAG,CAAC,wBAAwB,CAAC,kBAAkB,CAAC;IAChD,YAAY,CAAC,uBAAuB,CAAC;IACrC,UAAU,EAAE;IAUI,WAAA,MAAM,CAAC,IAAI,uBAAuB,oCAAoC,CAAC,CAAA;IACvE,WAAA,MAAM,CAAC,IAAI,uBAAuB,6CAA6C,CAAC,CAAA;IAChF,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;;GAXjC,2CAA2C,CAiCvD;SAjCY,2CAA2C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interceptors.js","sourceRoot":"","sources":["../../../../src/interceptors/interceptors.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"interceptors.js","sourceRoot":"","sources":["../../../../src/interceptors/interceptors.ts"],"names":[],"mappings":"AAAA,cAAc,oDAAoD,CAAC;AACnE,cAAc,sCAAsC,CAAC;AACrD,cAAc,gCAAgC,CAAC"}
|
|
@@ -23,11 +23,25 @@ import { injectable, inject } from "tsyringe";
|
|
|
23
23
|
import { moduleScoped, ServiceDefinitionTagEnum, tag } from "@pristine-ts/common";
|
|
24
24
|
import { NetworkingModuleKeyname } from "../networking.module.keyname";
|
|
25
25
|
import { InvalidBodyHttpError } from "../errors/invalid-body.http-error";
|
|
26
|
+
/**
|
|
27
|
+
* The Request Body Converter Interceptor intercepts the request and parses the body based on the Content-tTpe header.
|
|
28
|
+
* It is tagged as a RequestInterceptor so it can be automatically injected with the all the other RequestInterceptor.
|
|
29
|
+
*/
|
|
26
30
|
let RequestBodyConverterInterceptor = class RequestBodyConverterInterceptor {
|
|
31
|
+
/**
|
|
32
|
+
* The Request Body Converter Interceptor intercepts the request and parses the body based on the Content-Type header.
|
|
33
|
+
* It is tagged as a RequestInterceptor so it can be automatically injected with the all the other RequestInterceptor.
|
|
34
|
+
* @param isActive Whether or not this interceptor is active.
|
|
35
|
+
* @param logHandler The log handler to output logs.
|
|
36
|
+
*/
|
|
27
37
|
constructor(isActive, logHandler) {
|
|
28
38
|
this.isActive = isActive;
|
|
29
39
|
this.logHandler = logHandler;
|
|
30
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Intercepts the request and parses the body based on it's Content-Type header.
|
|
43
|
+
* @param request The request to intercept.
|
|
44
|
+
*/
|
|
31
45
|
interceptRequest(request) {
|
|
32
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
47
|
if (this.isActive === false) {
|
|
@@ -75,7 +89,7 @@ RequestBodyConverterInterceptor = __decorate([
|
|
|
75
89
|
tag(ServiceDefinitionTagEnum.RequestInterceptor),
|
|
76
90
|
moduleScoped(NetworkingModuleKeyname),
|
|
77
91
|
injectable(),
|
|
78
|
-
__param(0, inject("%" + NetworkingModuleKeyname + ".
|
|
92
|
+
__param(0, inject("%" + NetworkingModuleKeyname + ".requestBodyConverter.isActive%")),
|
|
79
93
|
__param(1, inject("LogHandlerInterface")),
|
|
80
94
|
__metadata("design:paramtypes", [Boolean, Object])
|
|
81
95
|
], RequestBodyConverterInterceptor);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-body-converter.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/request-body-converter.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAC,YAAY,EAAW,wBAAwB,EAAE,GAAG,EAAC,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAAC,oBAAoB,EAAC,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"request-body-converter.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/request-body-converter.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAC,YAAY,EAAW,wBAAwB,EAAE,GAAG,EAAC,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAAC,oBAAoB,EAAC,MAAM,mCAAmC,CAAC;AAEvE;;;GAGG;AAIH,IAAa,+BAA+B,GAA5C,MAAa,+BAA+B;IAExC;;;;;OAKG;IACH,YAAwG,QAAiB,EAC7D,UAA+B;QADa,aAAQ,GAAR,QAAQ,CAAS;QAC7D,eAAU,GAAV,UAAU,CAAqB;IAC3F,CAAC;IAED;;;OAGG;IACG,gBAAgB,CAAC,OAAgB;;YACnC,IAAG,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE;gBACxB,OAAO,OAAO,CAAC;aAClB;YAED,IAAG,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,KAAK,EAAE;gBAC5C,OAAO,OAAO,CAAC;aAClB;YAED,MAAM,WAAW,GAAW,OAAO,CAAC,SAAS,CAAC,cAAc,CAAW,CAAC;YAExE,QAAQ,WAAW,CAAC,WAAW,EAAE,EAAE;gBAC/B,KAAK,kBAAkB;oBAGnB,QAAQ,OAAO,OAAO,CAAC,IAAI,EAAE;wBACzB,KAAK,WAAW;4BACZ,OAAO,OAAO,CAAC;wBACnB,KAAK,QAAQ;4BACT,IAAG,OAAO,CAAC,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE;gCAClC,MAAM,YAAY,GAAG,kHAAkH,CAAC;gCACxI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;gCAEpC,MAAM,IAAI,oBAAoB,CAAC,YAAY,CAAC,CAAC;6BAChD;4BACD,OAAO,OAAO,CAAC;wBAEnB,KAAK,QAAQ;4BACT,IAAI;gCACA,IAAG,OAAO,CAAC,IAAI,EAAE;oCACb,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;iCAC3C;6BACJ;4BACD,OAAO,CAAC,EAAE;gCACN,MAAM,YAAY,GAAG,kIAAkI,CAAC;gCACxJ,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;gCAEpC,MAAM,IAAI,oBAAoB,CAAC,YAAY,CAAC,CAAC;6BAChD;4BACD,MAAM;wBAEV;4BACI,MAAM,YAAY,GAAG,iGAAiG,CAAC;4BACvH,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;4BAEpC,MAAM,IAAI,oBAAoB,CAAC,YAAY,CAAC,CAAC;qBACpD;aAGR;YAED,OAAO,OAAO,CAAC;QACnB,CAAC;KAAA;CAEJ,CAAA;AAtEY,+BAA+B;IAH3C,GAAG,CAAC,wBAAwB,CAAC,kBAAkB,CAAC;IAChD,YAAY,CAAC,uBAAuB,CAAC;IACrC,UAAU,EAAE;IASI,WAAA,MAAM,CAAC,GAAG,GAAG,uBAAuB,GAAG,iCAAiC,CAAC,CAAA;IACzE,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;;GATjC,+BAA+B,CAsE3C;SAtEY,+BAA+B"}
|
|
@@ -21,6 +21,12 @@ import { injectable } from "tsyringe";
|
|
|
21
21
|
* It is tagged as a RequestInterceptor so it can be automatically injected with the all the other RequestInterceptor.
|
|
22
22
|
*/
|
|
23
23
|
let ResponseHeadersInterceptor = class ResponseHeadersInterceptor {
|
|
24
|
+
/**
|
|
25
|
+
* Intercepts the response from the router and adds the headers specified by the response header decorator.
|
|
26
|
+
* @param response The response to intercept.
|
|
27
|
+
* @param request The request that triggered this response.
|
|
28
|
+
* @param methodNode The methode node.
|
|
29
|
+
*/
|
|
24
30
|
interceptResponse(response, request, methodNode) {
|
|
25
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
32
|
if (methodNode && methodNode.route.context && methodNode.route.context.hasOwnProperty("responseHeaders")) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-headers.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/response-headers.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAC,YAAY,EAAqB,wBAAwB,EAAE,GAAG,EAAC,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AAGrE,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC;;;GAGG;AAIH,IAAa,0BAA0B,GAAvC,MAAa,0BAA0B;
|
|
1
|
+
{"version":3,"file":"response-headers.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/response-headers.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAC,YAAY,EAAqB,wBAAwB,EAAE,GAAG,EAAC,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AAGrE,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC;;;GAGG;AAIH,IAAa,0BAA0B,GAAvC,MAAa,0BAA0B;IAEnC;;;;;OAKG;IACG,iBAAiB,CAAC,QAAkB,EAAE,OAAgB,EAAE,UAA6B;;YACvF,IAAG,UAAU,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAC;gBACpG,QAAQ,CAAC,UAAU,iCAAK,QAAQ,CAAC,OAAO,GAAK,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;aAC3F;YAED,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;CACJ,CAAA;AAfY,0BAA0B;IAHtC,GAAG,CAAC,wBAAwB,CAAC,kBAAkB,CAAC;IAChD,YAAY,CAAC,uBAAuB,CAAC;IACrC,UAAU,EAAE;GACA,0BAA0B,CAetC;SAfY,0BAA0B"}
|
|
@@ -20,13 +20,38 @@ export const NetworkingModule = {
|
|
|
20
20
|
TelemetryModule,
|
|
21
21
|
],
|
|
22
22
|
configurationDefinitions: [
|
|
23
|
+
/**
|
|
24
|
+
* Whether or not the request body converter interceptor is active.
|
|
25
|
+
*/
|
|
23
26
|
{
|
|
24
|
-
parameterName: NetworkingModuleKeyname + ".
|
|
27
|
+
parameterName: NetworkingModuleKeyname + ".requestBodyConverter.isActive",
|
|
25
28
|
isRequired: false,
|
|
26
29
|
defaultValue: true,
|
|
27
30
|
defaultResolvers: [
|
|
28
31
|
new BooleanResolver(new EnvironmentVariableResolver("PRISTINE_NETWORKING_REQUEST_BODY_CONVERTER_IS_ACTIVE")),
|
|
29
32
|
],
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* Whether or not the default content type response header interceptor is active.
|
|
36
|
+
*/
|
|
37
|
+
{
|
|
38
|
+
parameterName: NetworkingModuleKeyname + ".defaultContentTypeResponseHeader.isActive",
|
|
39
|
+
isRequired: false,
|
|
40
|
+
defaultValue: true,
|
|
41
|
+
defaultResolvers: [
|
|
42
|
+
new BooleanResolver(new EnvironmentVariableResolver("PRISTINE_NETWORKING_DEFAULT_CONTENT_TYPE_RESPONSE_HEADER_IS_ACTIVE")),
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
/**
|
|
46
|
+
* The default Content-Type response header to set on responses that do not already have Content-Types.
|
|
47
|
+
*/
|
|
48
|
+
{
|
|
49
|
+
parameterName: NetworkingModuleKeyname + ".defaultContentTypeResponseHeader",
|
|
50
|
+
isRequired: false,
|
|
51
|
+
defaultValue: "application/json",
|
|
52
|
+
defaultResolvers: [
|
|
53
|
+
new EnvironmentVariableResolver("PRISTINE_NETWORKING_DEFAULT_CONTENT_TYPE_RESPONSE_HEADER"),
|
|
54
|
+
],
|
|
30
55
|
}
|
|
31
56
|
],
|
|
32
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"networking.module.js","sourceRoot":"","sources":["../../../src/networking.module.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,uBAAuB,EAAC,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,eAAe,EAAE,2BAA2B,EAAC,MAAM,4BAA4B,CAAC;AAExF,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAE9B,cAAc,UAAU,CAAC;AAEzB,MAAM,CAAC,MAAM,gBAAgB,GAAoB;IAC7C,OAAO,EAAE,uBAAuB;IAChC,aAAa,EAAE;QACX,cAAc;QACd,eAAe;KAClB;IACD,wBAAwB,EAAE;QACtB;YACI,aAAa,EAAE,uBAAuB,GAAG,
|
|
1
|
+
{"version":3,"file":"networking.module.js","sourceRoot":"","sources":["../../../src/networking.module.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,uBAAuB,EAAC,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,eAAe,EAAE,2BAA2B,EAAC,MAAM,4BAA4B,CAAC;AAExF,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAE9B,cAAc,UAAU,CAAC;AAEzB,MAAM,CAAC,MAAM,gBAAgB,GAAoB;IAC7C,OAAO,EAAE,uBAAuB;IAChC,aAAa,EAAE;QACX,cAAc;QACd,eAAe;KAClB;IACD,wBAAwB,EAAE;QACtB;;WAEG;QACH;YACI,aAAa,EAAE,uBAAuB,GAAG,gCAAgC;YACzE,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,IAAI;YAClB,gBAAgB,EAAE;gBACd,IAAI,eAAe,CAAC,IAAI,2BAA2B,CAAC,sDAAsD,CAAC,CAAC;aAC/G;SACJ;QAED;;WAEG;QACH;YACI,aAAa,EAAE,uBAAuB,GAAG,4CAA4C;YACrF,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,IAAI;YAClB,gBAAgB,EAAE;gBACd,IAAI,eAAe,CAAC,IAAI,2BAA2B,CAAC,oEAAoE,CAAC,CAAC;aAC7H;SACJ;QAED;;WAEG;QACH;YACI,aAAa,EAAE,uBAAuB,GAAG,mCAAmC;YAC5E,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,kBAAkB;YAChC,gBAAgB,EAAE;gBACd,IAAI,2BAA2B,CAAC,0DAA0D,CAAC;aAC9F;SACJ;KACJ;CACJ,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Request, Response } from "@pristine-ts/common";
|
|
2
|
+
import { MethodRouterNode } from "../nodes/method-router.node";
|
|
3
|
+
import { RequestInterceptorInterface } from "../interfaces/request-interceptor.interface";
|
|
4
|
+
import { LogHandlerInterface } from "@pristine-ts/logging";
|
|
5
|
+
/**
|
|
6
|
+
* The Default ContentType Response Header Interceptor intercepts the response of the router and adds the default content-type header to the response.
|
|
7
|
+
* It is tagged as a RequestInterceptor so it can be automatically injected with the all the other RequestInterceptor.
|
|
8
|
+
*/
|
|
9
|
+
export declare class DefaultContentTypeResponseHeaderInterceptor implements RequestInterceptorInterface {
|
|
10
|
+
private readonly defaultContentTypeResponseHeader;
|
|
11
|
+
private readonly isActive;
|
|
12
|
+
private readonly logHandler;
|
|
13
|
+
/**
|
|
14
|
+
* The Default ContentType Response Header Interceptor intercepts the response of the router and adds the default content-type header to the response.
|
|
15
|
+
* It is tagged as a RequestInterceptor so it can be automatically injected with the all the other RequestInterceptor.
|
|
16
|
+
* @param defaultContentTypeResponseHeader The default Content-Type response header to set on responses that do not already have Content-Types.
|
|
17
|
+
* @param isActive Whether or not this interceptor is active.
|
|
18
|
+
* @param logHandler The log handler to output logs.
|
|
19
|
+
*/
|
|
20
|
+
constructor(defaultContentTypeResponseHeader: string, isActive: boolean, logHandler: LogHandlerInterface);
|
|
21
|
+
/**
|
|
22
|
+
* Intercepts the response from the router and adds the Content-Type header to it if it's not already there, with the default provided.
|
|
23
|
+
* @param response The response to intercept.
|
|
24
|
+
* @param request The request that triggered this response.
|
|
25
|
+
* @param methodNode The methode node.
|
|
26
|
+
*/
|
|
27
|
+
interceptResponse(response: Response, request: Request, methodNode?: MethodRouterNode): Promise<Response>;
|
|
28
|
+
}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { LogHandlerInterface } from "@pristine-ts/logging";
|
|
2
2
|
import { Request } from "@pristine-ts/common";
|
|
3
3
|
import { RequestInterceptorInterface } from "../interfaces/request-interceptor.interface";
|
|
4
|
+
/**
|
|
5
|
+
* The Request Body Converter Interceptor intercepts the request and parses the body based on the Content-tTpe header.
|
|
6
|
+
* It is tagged as a RequestInterceptor so it can be automatically injected with the all the other RequestInterceptor.
|
|
7
|
+
*/
|
|
4
8
|
export declare class RequestBodyConverterInterceptor implements RequestInterceptorInterface {
|
|
5
9
|
private readonly isActive;
|
|
6
10
|
private readonly logHandler;
|
|
11
|
+
/**
|
|
12
|
+
* The Request Body Converter Interceptor intercepts the request and parses the body based on the Content-Type header.
|
|
13
|
+
* It is tagged as a RequestInterceptor so it can be automatically injected with the all the other RequestInterceptor.
|
|
14
|
+
* @param isActive Whether or not this interceptor is active.
|
|
15
|
+
* @param logHandler The log handler to output logs.
|
|
16
|
+
*/
|
|
7
17
|
constructor(isActive: boolean, logHandler: LogHandlerInterface);
|
|
18
|
+
/**
|
|
19
|
+
* Intercepts the request and parses the body based on it's Content-Type header.
|
|
20
|
+
* @param request The request to intercept.
|
|
21
|
+
*/
|
|
8
22
|
interceptRequest(request: Request): Promise<Request>;
|
|
9
23
|
}
|
|
@@ -6,5 +6,11 @@ import { RequestInterceptorInterface } from "../interfaces/request-interceptor.i
|
|
|
6
6
|
* It is tagged as a RequestInterceptor so it can be automatically injected with the all the other RequestInterceptor.
|
|
7
7
|
*/
|
|
8
8
|
export declare class ResponseHeadersInterceptor implements RequestInterceptorInterface {
|
|
9
|
+
/**
|
|
10
|
+
* Intercepts the response from the router and adds the headers specified by the response header decorator.
|
|
11
|
+
* @param response The response to intercept.
|
|
12
|
+
* @param request The request that triggered this response.
|
|
13
|
+
* @param methodNode The methode node.
|
|
14
|
+
*/
|
|
9
15
|
interceptResponse(response: Response, request: Request, methodNode?: MethodRouterNode): Promise<Response>;
|
|
10
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pristine-ts/networking",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.193",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "dist/lib/esm/networking.module.js",
|
|
6
6
|
"main": "dist/lib/cjs/networking.module.js",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@pristine-ts/common": "^0.0.
|
|
24
|
-
"@pristine-ts/core": "^0.0.
|
|
25
|
-
"@pristine-ts/security": "^0.0.
|
|
26
|
-
"@pristine-ts/telemetry": "^0.0.
|
|
23
|
+
"@pristine-ts/common": "^0.0.193",
|
|
24
|
+
"@pristine-ts/core": "^0.0.193",
|
|
25
|
+
"@pristine-ts/security": "^0.0.193",
|
|
26
|
+
"@pristine-ts/telemetry": "^0.0.193",
|
|
27
27
|
"lodash": "^4.17.21",
|
|
28
28
|
"url-parse": "^1.4.7"
|
|
29
29
|
},
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"src/*.{js,ts}"
|
|
62
62
|
]
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "1595a3af0a2857aabe8670486d3208fbc7253984"
|
|
65
65
|
}
|