@lad-tech/nsc-toolkit 1.17.2 → 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 CHANGED
@@ -1,6 +1,6 @@
1
- ## [1.17.2](https://github.com/lad-tech/nsc-toolkit/compare/v1.17.1...v1.17.2) (2023-11-13)
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
- * JavaScript heap out of memory in BufferToJsonTransform.ts ([71ca579](https://github.com/lad-tech/nsc-toolkit/commit/71ca57990a2f25a1707cc43dbd7c10398de518e7))
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
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lad-tech/nsc-toolkit",
3
- "version": "1.17.2",
3
+ "version": "1.17.3",
4
4
  "description": "Toolkit for create microservices around NATS",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/types/index.d.ts",