ismx-nexo-node-app 0.4.48 → 0.4.50

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.
@@ -52,15 +52,16 @@ class BusinessProxy {
52
52
  throw new Error(`Module ${tag} does not exist`);
53
53
  // Completa la información de las cabeceras con cabeceras comunes por llamada a API.
54
54
  let headers = new node_fetch_1.Headers(request.headers);
55
- headers.set('Content-Type', 'application/json');
56
55
  headers.set('Cache-Control', 'no-cache');
57
56
  headers.set('Pragma', 'no-cache');
58
57
  for (const header of Object.keys(headers))
59
58
  headers.set(header, (_b = (_a = request.headers) === null || _a === void 0 ? void 0 : _a[header]) !== null && _b !== void 0 ? _b : "");
60
59
  // Si el body especificado es un objeto, lo convierte a JSON.
61
- let body = request.body;
62
- if ((_c = headers.get('Content-Type')) === null || _c === void 0 ? void 0 : _c.startsWith('application/json'))
60
+ let body = (_c = request.body) === null || _c === void 0 ? void 0 : _c.toString();
61
+ if (request.body && typeof request.body !== 'string') {
62
+ headers.set('Content-Type', 'application/json');
63
63
  body = JSON.stringify(request.body);
64
+ }
64
65
  // Realiza la llamada a la API con las cabeceras y la URL base de la llamada.
65
66
  try {
66
67
  return (0, node_fetch_1.default)(module.host + endpoint + QueryUtils_1.default.map(request.query), Object.assign(Object.assign({}, request), { method, body: method !== "GET" ? body : undefined, headers }));
@@ -32,15 +32,16 @@ class RepositoryRest extends Repository_1.default {
32
32
  request = (_c = (_b = (_a = this.options).interceptor) === null || _b === void 0 ? void 0 : _b.call(_a, endpoint, request)) !== null && _c !== void 0 ? _c : request;
33
33
  // Completa la información de las cabeceras con cabeceras comunes por llamada a API.
34
34
  let headers = new Headers(request.headers);
35
- headers.set('Content-Type', 'application/json');
36
35
  headers.set('Cache-Control', 'no-cache');
37
36
  headers.set('Pragma', 'no-cache');
38
37
  for (const header of Object.keys(headers))
39
38
  headers.set(header, (_e = (_d = request.headers) === null || _d === void 0 ? void 0 : _d[header]) !== null && _e !== void 0 ? _e : "");
40
39
  // Si el body especificado es un objeto, lo convierte a JSON.
41
- let body = request.body;
42
- if ((_f = headers.get('Content-Type')) === null || _f === void 0 ? void 0 : _f.startsWith('application/json'))
40
+ let body = (_f = request.body) === null || _f === void 0 ? void 0 : _f.toString();
41
+ if (request.body && typeof request.body !== 'string') {
42
+ headers.set('Content-Type', 'application/json');
43
43
  body = JSON.stringify(request.body);
44
+ }
44
45
  // Realiza la llamada a la API con las cabeceras y la URL base de la llamada.
45
46
  let call = fetch(this.baseUrl + endpoint + QueryUtils_1.default.map(request.query), Object.assign(Object.assign({}, request), { body: method !== "GET" ? body : undefined, headers }));
46
47
  // Añade información adicional a la respuesta y devuelve el resultado (o el error en su caso).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.48",
3
+ "version": "0.4.50",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -1,7 +1,7 @@
1
1
  import { HttpResponse, HttpRequest } from "../api/Service"
2
2
  import fetch, {Body, Headers} from 'node-fetch';
3
- import {Wrapper} from "../api/ServiceRestFormal";
4
3
  import QueryUtils from "../repository/utils/QueryUtils";
4
+ import {json} from "express";
5
5
 
6
6
  export interface Module {
7
7
  id: string;
@@ -21,19 +21,19 @@ export default class BusinessProxy
21
21
  let module = this.modules[tag];
22
22
  if (!module) throw new Error(`Module ${tag} does not exist`);
23
23
 
24
-
25
24
  // Completa la información de las cabeceras con cabeceras comunes por llamada a API.
26
25
  let headers = new Headers(request.headers);
27
- headers.set('Content-Type', 'application/json');
28
26
  headers.set('Cache-Control', 'no-cache');
29
27
  headers.set('Pragma', 'no-cache');
30
28
  for (const header of Object.keys(headers))
31
29
  headers.set(header, request.headers?.[header] ?? "");
32
30
 
33
31
  // Si el body especificado es un objeto, lo convierte a JSON.
34
- let body: string = request.body as string;
35
- if (headers.get('Content-Type')?.startsWith('application/json'))
32
+ let body: string | undefined = request.body?.toString();
33
+ if (request.body && typeof request.body !== 'string') {
34
+ headers.set('Content-Type', 'application/json');
36
35
  body = JSON.stringify(request.body);
36
+ }
37
37
 
38
38
  // Realiza la llamada a la API con las cabeceras y la URL base de la llamada.
39
39
  try {
@@ -40,16 +40,17 @@ export default class RepositoryRest<Body=any,Res=any> extends Repository
40
40
 
41
41
  // Completa la información de las cabeceras con cabeceras comunes por llamada a API.
42
42
  let headers = new Headers(request.headers);
43
- headers.set('Content-Type', 'application/json');
44
43
  headers.set('Cache-Control', 'no-cache');
45
44
  headers.set('Pragma', 'no-cache');
46
45
  for (const header of Object.keys(headers))
47
46
  headers.set(header, request.headers?.[header] ?? "");
48
47
 
49
48
  // Si el body especificado es un objeto, lo convierte a JSON.
50
- let body: string = request.body as string;
51
- if (headers.get('Content-Type')?.startsWith('application/json'))
49
+ let body: string | undefined = request.body?.toString();
50
+ if (request.body && typeof request.body !== 'string') {
51
+ headers.set('Content-Type', 'application/json');
52
52
  body = JSON.stringify(request.body);
53
+ }
53
54
 
54
55
  // Realiza la llamada a la API con las cabeceras y la URL base de la llamada.
55
56
  let call = fetch(this.baseUrl + endpoint + QueryUtils.map(request.query), {