ismx-nexo-node-app 0.4.41 → 0.4.43

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.
@@ -71,8 +71,12 @@ class BusinessProxy {
71
71
  catch (error) {
72
72
  throw new Error(`Module ${tag} is not responding`);
73
73
  }
74
- if (response.ok)
75
- return yield response.json();
74
+ if (response.ok) {
75
+ if (response.headers.get('Content-Type') === 'application/json')
76
+ return yield response.json();
77
+ else
78
+ return yield response.text();
79
+ }
76
80
  else
77
81
  throw yield response.json();
78
82
  });
@@ -109,7 +109,7 @@ class BusinessServer extends Business_1.default {
109
109
  }
110
110
  run(service) {
111
111
  return (request, socket) => __awaiter(this, void 0, void 0, function* () {
112
- var _a, _b, _c, _d, _e, _f, _g, _h;
112
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
113
113
  let code;
114
114
  let response = Service_1.HttpResponse.ko(500, "Internal server error");
115
115
  // Asigna un valor único a la llamada de la API.
@@ -141,10 +141,13 @@ class BusinessServer extends Business_1.default {
141
141
  response = Service_1.HttpResponse.ko(500, null);
142
142
  }
143
143
  finally {
144
- let status = (_g = response === null || response === void 0 ? void 0 : response.httpCode) !== null && _g !== void 0 ? _g : 500;
145
- socket.status(status).send(response === null || response === void 0 ? void 0 : response.content);
144
+ socket.status((_g = response === null || response === void 0 ? void 0 : response.httpCode) !== null && _g !== void 0 ? _g : 500);
145
+ Object.entries((_h = response.headers) !== null && _h !== void 0 ? _h : {}).forEach(([header, value]) => {
146
+ socket.set(header, value);
147
+ });
148
+ socket.send(response === null || response === void 0 ? void 0 : response.content);
146
149
  try {
147
- (_h = this.onEnd) === null || _h === void 0 ? void 0 : _h.call(this, request, response);
150
+ (_j = this.onEnd) === null || _j === void 0 ? void 0 : _j.call(this, request, response);
148
151
  }
149
152
  catch (e) { }
150
153
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.41",
3
+ "version": "0.4.43",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -42,7 +42,10 @@ export default class BusinessProxy
42
42
  });
43
43
  } catch (error) { throw new Error(`Module ${tag} is not responding`); }
44
44
 
45
- if (response.ok) return await response.json();
45
+ if (response.ok) {
46
+ if (response.headers.get('Content-Type') === 'application/json') return await response.json();
47
+ else return await response.text() as Res;
48
+ }
46
49
  else throw await response.json();
47
50
  }
48
51
 
@@ -103,8 +103,11 @@ export default class BusinessServer extends Business
103
103
  else response = HttpResponse.ko(500, null);
104
104
 
105
105
  } finally {
106
- let status = response?.httpCode ?? 500;
107
- socket.status(status).send(response?.content);
106
+ socket.status(response?.httpCode ?? 500)
107
+ Object.entries(response.headers ?? {}).forEach(([header, value]) => {
108
+ socket.set(header, value);
109
+ });
110
+ socket.send(response?.content);
108
111
  try { this.onEnd?.(request, response); } catch(e) { }
109
112
  }
110
113
  }}