c2-http 1.0.19 → 1.0.22
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 +4 -0
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "CrudController", { enumerable: true, get: functi
|
|
|
20
20
|
const HttpError_1 = require("./model/HttpError");
|
|
21
21
|
const Server_1 = require("./model/Server");
|
|
22
22
|
Object.defineProperty(exports, "Server", { enumerable: true, get: function () { return Server_1.Server; } });
|
|
23
|
+
const axios_1 = __importDefault(require("axios"));
|
|
23
24
|
const convertErrorToHttpError = (error) => {
|
|
24
25
|
if (error instanceof mongodb_1.MongoServerError) {
|
|
25
26
|
if (error.code === 11000) {
|
|
@@ -31,6 +32,9 @@ const convertErrorToHttpError = (error) => {
|
|
|
31
32
|
const fields = Object.keys(error.errors);
|
|
32
33
|
return new HttpError_1.HttpError(http_status_1.NOT_ACCEPTABLE, (0, i18n_1.getMessage)("message.fieldIsRequired", fields.join(", ")), error.errors);
|
|
33
34
|
}
|
|
35
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
36
|
+
return new HttpError_1.HttpError(error.status, error.message, error.response?.data);
|
|
37
|
+
}
|
|
34
38
|
if (error instanceof HttpError_1.HttpError) {
|
|
35
39
|
return error;
|
|
36
40
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c2-http",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"description": "Biblioteca Typescript para API NodeJS",
|
|
5
5
|
"repository": "https://cabralsilva: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@github.com/cabralsilva/c2-http.git",
|
|
6
6
|
"author": "Daniel Cabral <cabralconsultoriaemsoftware@gmail.com>",
|
|
@@ -19,9 +19,11 @@
|
|
|
19
19
|
"publish-major": "npm version major"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
+
"@types/axios": "^0.14.0",
|
|
22
23
|
"@types/express": "^4.17.21",
|
|
23
24
|
"@types/http-status": "^1.1.2",
|
|
24
25
|
"@types/mongoose": "^5.11.97",
|
|
26
|
+
"axios": "^1.6.8",
|
|
25
27
|
"c2-util": "^1.0.13",
|
|
26
28
|
"express": "^4.19.2",
|
|
27
29
|
"express-http-context": "^1.2.4",
|