@gustavo-valsechi/node 1.0.11 → 1.0.13

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/index.js CHANGED
@@ -85,13 +85,14 @@ var responseWrapper = async (res, promise) => {
85
85
  return promise.then((data) => {
86
86
  res.status(200).send(data);
87
87
  }).catch((err) => {
88
- const status = err.statusCode || 422;
89
- if (err.response && err.response.data) {
90
- console.error(err.response);
91
- return res.status(status).send(err.response.data);
92
- }
93
- console.error(err);
94
- return res.status(status).send({ message: err.message, type: err.type, code: err.code });
88
+ var _a;
89
+ const status = err.statusCode || 500;
90
+ console.error("\u{1F534} Request error", (err == null ? void 0 : err.response) || err);
91
+ return res.status(status).send({
92
+ statusCode: status,
93
+ code: err.code,
94
+ response: ((_a = err == null ? void 0 : err.response) == null ? void 0 : _a.data) || err.message
95
+ });
95
96
  });
96
97
  };
97
98
 
package/dist/index.mjs CHANGED
@@ -45,13 +45,14 @@ var responseWrapper = async (res, promise) => {
45
45
  return promise.then((data) => {
46
46
  res.status(200).send(data);
47
47
  }).catch((err) => {
48
- const status = err.statusCode || 422;
49
- if (err.response && err.response.data) {
50
- console.error(err.response);
51
- return res.status(status).send(err.response.data);
52
- }
53
- console.error(err);
54
- return res.status(status).send({ message: err.message, type: err.type, code: err.code });
48
+ var _a;
49
+ const status = err.statusCode || 500;
50
+ console.error("\u{1F534} Request error", (err == null ? void 0 : err.response) || err);
51
+ return res.status(status).send({
52
+ statusCode: status,
53
+ code: err.code,
54
+ response: ((_a = err == null ? void 0 : err.response) == null ? void 0 : _a.data) || err.message
55
+ });
55
56
  });
56
57
  };
57
58
 
@@ -40,13 +40,14 @@ var responseWrapper = async (res, promise) => {
40
40
  return promise.then((data) => {
41
41
  res.status(200).send(data);
42
42
  }).catch((err) => {
43
- const status = err.statusCode || 422;
44
- if (err.response && err.response.data) {
45
- console.error(err.response);
46
- return res.status(status).send(err.response.data);
47
- }
48
- console.error(err);
49
- return res.status(status).send({ message: err.message, type: err.type, code: err.code });
43
+ var _a;
44
+ const status = err.statusCode || 500;
45
+ console.error("\u{1F534} Request error", (err == null ? void 0 : err.response) || err);
46
+ return res.status(status).send({
47
+ statusCode: status,
48
+ code: err.code,
49
+ response: ((_a = err == null ? void 0 : err.response) == null ? void 0 : _a.data) || err.message
50
+ });
50
51
  });
51
52
  };
52
53
 
@@ -3,13 +3,14 @@ var responseWrapper = async (res, promise) => {
3
3
  return promise.then((data) => {
4
4
  res.status(200).send(data);
5
5
  }).catch((err) => {
6
- const status = err.statusCode || 422;
7
- if (err.response && err.response.data) {
8
- console.error(err.response);
9
- return res.status(status).send(err.response.data);
10
- }
11
- console.error(err);
12
- return res.status(status).send({ message: err.message, type: err.type, code: err.code });
6
+ var _a;
7
+ const status = err.statusCode || 500;
8
+ console.error("\u{1F534} Request error", (err == null ? void 0 : err.response) || err);
9
+ return res.status(status).send({
10
+ statusCode: status,
11
+ code: err.code,
12
+ response: ((_a = err == null ? void 0 : err.response) == null ? void 0 : _a.data) || err.message
13
+ });
13
14
  });
14
15
  };
15
16
 
@@ -41,13 +41,14 @@ var responseWrapper = async (res, promise) => {
41
41
  return promise.then((data) => {
42
42
  res.status(200).send(data);
43
43
  }).catch((err) => {
44
- const status = err.statusCode || 422;
45
- if (err.response && err.response.data) {
46
- console.error(err.response);
47
- return res.status(status).send(err.response.data);
48
- }
49
- console.error(err);
50
- return res.status(status).send({ message: err.message, type: err.type, code: err.code });
44
+ var _a;
45
+ const status = err.statusCode || 500;
46
+ console.error("\u{1F534} Request error", (err == null ? void 0 : err.response) || err);
47
+ return res.status(status).send({
48
+ statusCode: status,
49
+ code: err.code,
50
+ response: ((_a = err == null ? void 0 : err.response) == null ? void 0 : _a.data) || err.message
51
+ });
51
52
  });
52
53
  };
53
54
 
@@ -6,13 +6,14 @@ var responseWrapper = async (res, promise) => {
6
6
  return promise.then((data) => {
7
7
  res.status(200).send(data);
8
8
  }).catch((err) => {
9
- const status = err.statusCode || 422;
10
- if (err.response && err.response.data) {
11
- console.error(err.response);
12
- return res.status(status).send(err.response.data);
13
- }
14
- console.error(err);
15
- return res.status(status).send({ message: err.message, type: err.type, code: err.code });
9
+ var _a;
10
+ const status = err.statusCode || 500;
11
+ console.error("\u{1F534} Request error", (err == null ? void 0 : err.response) || err);
12
+ return res.status(status).send({
13
+ statusCode: status,
14
+ code: err.code,
15
+ response: ((_a = err == null ? void 0 : err.response) == null ? void 0 : _a.data) || err.message
16
+ });
16
17
  });
17
18
  };
18
19
 
@@ -45,13 +45,14 @@ var responseWrapper = async (res, promise) => {
45
45
  return promise.then((data) => {
46
46
  res.status(200).send(data);
47
47
  }).catch((err) => {
48
- const status = err.statusCode || 422;
49
- if (err.response && err.response.data) {
50
- console.error(err.response);
51
- return res.status(status).send(err.response.data);
52
- }
53
- console.error(err);
54
- return res.status(status).send({ message: err.message, type: err.type, code: err.code });
48
+ var _a;
49
+ const status = err.statusCode || 500;
50
+ console.error("\u{1F534} Request error", (err == null ? void 0 : err.response) || err);
51
+ return res.status(status).send({
52
+ statusCode: status,
53
+ code: err.code,
54
+ response: ((_a = err == null ? void 0 : err.response) == null ? void 0 : _a.data) || err.message
55
+ });
55
56
  });
56
57
  };
57
58
 
@@ -10,13 +10,14 @@ var responseWrapper = async (res, promise) => {
10
10
  return promise.then((data) => {
11
11
  res.status(200).send(data);
12
12
  }).catch((err) => {
13
- const status = err.statusCode || 422;
14
- if (err.response && err.response.data) {
15
- console.error(err.response);
16
- return res.status(status).send(err.response.data);
17
- }
18
- console.error(err);
19
- return res.status(status).send({ message: err.message, type: err.type, code: err.code });
13
+ var _a;
14
+ const status = err.statusCode || 500;
15
+ console.error("\u{1F534} Request error", (err == null ? void 0 : err.response) || err);
16
+ return res.status(status).send({
17
+ statusCode: status,
18
+ code: err.code,
19
+ response: ((_a = err == null ? void 0 : err.response) == null ? void 0 : _a.data) || err.message
20
+ });
20
21
  });
21
22
  };
22
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/node",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",