@pristine-ts/core 0.0.144 → 0.0.148
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/request-body-converter.interceptor.js +19 -7
- package/dist/lib/cjs/interceptors/request-body-converter.interceptor.js.map +1 -1
- package/dist/lib/esm/interceptors/request-body-converter.interceptor.js +19 -7
- package/dist/lib/esm/interceptors/request-body-converter.interceptor.js.map +1 -1
- package/package.json +9 -9
|
@@ -52,13 +52,25 @@ let RequestBodyConverterInterceptor = class RequestBodyConverterInterceptor {
|
|
|
52
52
|
}
|
|
53
53
|
switch (contentType.toLowerCase()) {
|
|
54
54
|
case "application/json":
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
switch (typeof request.body) {
|
|
56
|
+
case "object":
|
|
57
|
+
return request;
|
|
58
|
+
case "string":
|
|
59
|
+
try {
|
|
60
|
+
if (request.body) {
|
|
61
|
+
request.body = JSON.parse(request.body);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
const errorMessage = "This request has the Content-Type header 'application/json' but the body contains invalid JSON.";
|
|
66
|
+
this.logHandler.error(errorMessage);
|
|
67
|
+
throw new networking_1.InvalidBodyHttpError(errorMessage);
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
const errorMessage = "This request has the Content-Type header 'application/json' but the body contains invalid JSON.";
|
|
72
|
+
this.logHandler.error(errorMessage);
|
|
73
|
+
throw new networking_1.InvalidBodyHttpError(errorMessage);
|
|
62
74
|
}
|
|
63
75
|
}
|
|
64
76
|
return request;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-body-converter.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/request-body-converter.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,uCAA4C;AAK5C,gDAAgF;AAChF,wDAA6D;AAE7D,gEAAyD;AAKzD,IAAa,+BAA+B,GAA5C,MAAa,+BAA+B;IACxC,YAA+F,QAAiB,EACpD,UAA+B;QADI,aAAQ,GAAR,QAAQ,CAAS;QACpD,eAAU,GAAV,UAAU,CAAqB;IAC3F,CAAC;IAEK,gBAAgB,CAAC,OAAgB;;YACnC,IAAG,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE;gBACxB,OAAO,OAAO,CAAC;aAClB;YAED,IAAI,WAA+B,CAAC;YAEpC,KAAK,IAAI,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE;gBAC7B,IAAI,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE;oBAC/C,SAAS;iBACZ;gBAED,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBAE3C,IAAG,GAAG,CAAC,WAAW,EAAE,KAAK,cAAc,EAAE;oBACrC,WAAW,GAAG,aAAa,CAAC;oBAC5B,MAAM;iBACT;aACJ;YAED,IAAG,WAAW,KAAK,SAAS,EAAE;gBAC1B,OAAO,OAAO,CAAC;aAClB;YAED,QAAQ,WAAW,CAAC,WAAW,EAAE,EAAE;gBAC/B,KAAK,kBAAkB;oBAEnB,IAAI;
|
|
1
|
+
{"version":3,"file":"request-body-converter.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/request-body-converter.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,uCAA4C;AAK5C,gDAAgF;AAChF,wDAA6D;AAE7D,gEAAyD;AAKzD,IAAa,+BAA+B,GAA5C,MAAa,+BAA+B;IACxC,YAA+F,QAAiB,EACpD,UAA+B;QADI,aAAQ,GAAR,QAAQ,CAAS;QACpD,eAAU,GAAV,UAAU,CAAqB;IAC3F,CAAC;IAEK,gBAAgB,CAAC,OAAgB;;YACnC,IAAG,IAAI,CAAC,QAAQ,K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,+BAA+B;IAH3C,YAAG,CAAC,iCAAwB,CAAC,kBAAkB,CAAC;IAChD,qBAAY,CAAC,uCAAiB,CAAC;IAC/B,qBAAU,EAAE;IAEI,WAAA,iBAAM,CAAC,GAAG,GAAG,uCAAiB,GAAG,8BAA8B,CAAC,CAAA;IAChE,WAAA,iBAAM,CAAC,qBAAqB,CAAC,CAAA;;GAFjC,+BAA+B,CA+D3C;AA/DY,0EAA+B"}
|
|
@@ -49,13 +49,25 @@ let RequestBodyConverterInterceptor = class RequestBodyConverterInterceptor {
|
|
|
49
49
|
}
|
|
50
50
|
switch (contentType.toLowerCase()) {
|
|
51
51
|
case "application/json":
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
switch (typeof request.body) {
|
|
53
|
+
case "object":
|
|
54
|
+
return request;
|
|
55
|
+
case "string":
|
|
56
|
+
try {
|
|
57
|
+
if (request.body) {
|
|
58
|
+
request.body = JSON.parse(request.body);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
const errorMessage = "This request has the Content-Type header 'application/json' but the body contains invalid JSON.";
|
|
63
|
+
this.logHandler.error(errorMessage);
|
|
64
|
+
throw new InvalidBodyHttpError(errorMessage);
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
const errorMessage = "This request has the Content-Type header 'application/json' but the body contains invalid JSON.";
|
|
69
|
+
this.logHandler.error(errorMessage);
|
|
70
|
+
throw new InvalidBodyHttpError(errorMessage);
|
|
59
71
|
}
|
|
60
72
|
}
|
|
61
73
|
return request;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-body-converter.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/request-body-converter.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAK5C,OAAO,EAAC,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAC,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAC,oBAAoB,EAAC,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AAKzD,IAAa,+BAA+B,GAA5C,MAAa,+BAA+B;IACxC,YAA+F,QAAiB,EACpD,UAA+B;QADI,aAAQ,GAAR,QAAQ,CAAS;QACpD,eAAU,GAAV,UAAU,CAAqB;IAC3F,CAAC;IAEK,gBAAgB,CAAC,OAAgB;;YACnC,IAAG,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE;gBACxB,OAAO,OAAO,CAAC;aAClB;YAED,IAAI,WAA+B,CAAC;YAEpC,KAAK,IAAI,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE;gBAC7B,IAAI,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE;oBAC/C,SAAS;iBACZ;gBAED,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBAE3C,IAAG,GAAG,CAAC,WAAW,EAAE,KAAK,cAAc,EAAE;oBACrC,WAAW,GAAG,aAAa,CAAC;oBAC5B,MAAM;iBACT;aACJ;YAED,IAAG,WAAW,KAAK,SAAS,EAAE;gBAC1B,OAAO,OAAO,CAAC;aAClB;YAED,QAAQ,WAAW,CAAC,WAAW,EAAE,EAAE;gBAC/B,KAAK,kBAAkB;oBAEnB,IAAI;
|
|
1
|
+
{"version":3,"file":"request-body-converter.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/request-body-converter.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAK5C,OAAO,EAAC,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAC,MAAM,qBAAqB,CAAC;A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Y,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;AA/DY,+BAA+B;IAH3C,GAAG,CAAC,wBAAwB,CAAC,kBAAkB,CAAC;IAChD,YAAY,CAAC,iBAAiB,CAAC;IAC/B,UAAU,EAAE;IAEI,WAAA,MAAM,CAAC,GAAG,GAAG,iBAAiB,GAAG,8BAA8B,CAAC,CAAA;IAChE,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;;GAFjC,+BAA+B,CA+D3C;SA/DY,+BAA+B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pristine-ts/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.148",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "dist/lib/esm/core.module.js",
|
|
6
6
|
"main": "dist/lib/cjs/core.module.js",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@pristine-ts/common": "^0.0.
|
|
23
|
-
"@pristine-ts/configuration": "^0.0.
|
|
24
|
-
"@pristine-ts/event": "^0.0.
|
|
25
|
-
"@pristine-ts/logging": "^0.0.
|
|
26
|
-
"@pristine-ts/networking": "^0.0.
|
|
27
|
-
"@pristine-ts/security": "^0.0.
|
|
28
|
-
"@pristine-ts/telemetry": "^0.0.
|
|
22
|
+
"@pristine-ts/common": "^0.0.148",
|
|
23
|
+
"@pristine-ts/configuration": "^0.0.148",
|
|
24
|
+
"@pristine-ts/event": "^0.0.148",
|
|
25
|
+
"@pristine-ts/logging": "^0.0.148",
|
|
26
|
+
"@pristine-ts/networking": "^0.0.148",
|
|
27
|
+
"@pristine-ts/security": "^0.0.148",
|
|
28
|
+
"@pristine-ts/telemetry": "^0.0.148",
|
|
29
29
|
"lodash": "^4.17.21",
|
|
30
30
|
"reflect-metadata": "^0.1.13",
|
|
31
31
|
"tsyringe": "^4.4.0"
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"src/*.{js,ts}"
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "7f7675b64adb1659a49c1881d28d22a5bcf175a3"
|
|
68
68
|
}
|