@lad-tech/nsc-toolkit 1.17.1 → 1.17.3
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 +2 -2
- package/dist/Client.js +1 -1
- package/dist/Service.js +2 -1
- package/dist/StreamOptions/BufferToJsonTransform.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
## [1.17.
|
|
1
|
+
## [1.17.3](https://github.com/lad-tech/nsc-toolkit/compare/v1.17.2...v1.17.3) (2023-11-17)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* Throw error if http response 500 ([#90](https://github.com/lad-tech/nsc-toolkit/issues/90)) ([536b5ce](https://github.com/lad-tech/nsc-toolkit/commit/536b5ce6ee43e900367d5eb2d45bc302ad471e1f))
|
package/dist/Client.js
CHANGED
|
@@ -205,7 +205,7 @@ class Client extends Root_1.Root {
|
|
|
205
205
|
timeout,
|
|
206
206
|
}, async (response) => {
|
|
207
207
|
var _a;
|
|
208
|
-
if ((_a = options === null || options === void 0 ? void 0 : options.useStream) === null || _a === void 0 ? void 0 : _a.response) {
|
|
208
|
+
if (((_a = options === null || options === void 0 ? void 0 : options.useStream) === null || _a === void 0 ? void 0 : _a.response) && response.statusCode !== 500) {
|
|
209
209
|
resolve({ payload: response });
|
|
210
210
|
return;
|
|
211
211
|
}
|
package/dist/Service.js
CHANGED
|
@@ -228,9 +228,10 @@ class Service extends Root_1.Root {
|
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
makeHttpSingleResponse(response, data) {
|
|
231
|
+
const isError = !data.payload && data.error && data.error.message;
|
|
231
232
|
const responseData = JSON.stringify(data);
|
|
232
233
|
response
|
|
233
|
-
.writeHead(200, {
|
|
234
|
+
.writeHead(isError ? 500 : 200, {
|
|
234
235
|
'Content-Length': Buffer.byteLength(responseData),
|
|
235
236
|
'Content-Type': 'application/json',
|
|
236
237
|
})
|
|
@@ -13,6 +13,7 @@ class BufferToJsonTransform extends stream_1.Transform {
|
|
|
13
13
|
tail = Buffer.concat([this.head, Buffer.from(tail)]);
|
|
14
14
|
const jsonData = JSON.parse(tail.toString());
|
|
15
15
|
cb(null, jsonData);
|
|
16
|
+
this.head = Buffer.from('');
|
|
16
17
|
}
|
|
17
18
|
catch (error) {
|
|
18
19
|
if (error instanceof SyntaxError) {
|