@companieshouse/api-sdk-node 2.0.63 → 2.0.64
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.
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const http_client_1 = require("./http-client");
|
|
16
|
-
const
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
17
|
/**
|
|
18
18
|
* RequestClient is an implementation of our http client using the request
|
|
19
19
|
* library.
|
|
@@ -49,30 +49,28 @@ class RequestClient extends http_client_1.AbstractClient {
|
|
|
49
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
50
|
try {
|
|
51
51
|
const options = {
|
|
52
|
-
baseUrl: this.options.baseUrl,
|
|
53
|
-
uri: additionalOptions.url,
|
|
54
52
|
method: additionalOptions.method,
|
|
55
53
|
headers: Object.assign(Object.assign({}, this.headers), additionalOptions.headers),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
url: `${this.options.baseUrl}{additionalOptions.url}`,
|
|
55
|
+
data: additionalOptions.body,
|
|
56
|
+
responseType: "json",
|
|
57
|
+
validateStatus: () => true
|
|
59
58
|
};
|
|
60
59
|
// any errors (including status code errors) are thrown as exceptions and
|
|
61
60
|
// will be caught in the catch block.
|
|
62
|
-
const resp = yield
|
|
61
|
+
const resp = yield axios_1.default(options);
|
|
63
62
|
return {
|
|
64
|
-
status: resp.
|
|
65
|
-
body: resp.
|
|
63
|
+
status: resp.status,
|
|
64
|
+
body: resp.data,
|
|
66
65
|
headers: resp.headers
|
|
67
66
|
};
|
|
68
67
|
}
|
|
69
68
|
catch (e) {
|
|
70
|
-
// e
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
const error = ((_a = e === null || e === void 0 ? void 0 : e.response) === null || _a === void 0 ? void 0 : _a.body) || { message: "failed to execute http request" };
|
|
69
|
+
// e can be an instance of AxiosError or a generic error
|
|
70
|
+
// however, we cannot specify a type for e coz type annotations for catch block errors must be 'any' or 'unknown' if specified
|
|
71
|
+
const error = ((_a = e === null || e === void 0 ? void 0 : e.response) === null || _a === void 0 ? void 0 : _a.data) || { message: "failed to execute http request" };
|
|
74
72
|
return {
|
|
75
|
-
status: (e === null || e === void 0 ? void 0 : e.
|
|
73
|
+
status: (e === null || e === void 0 ? void 0 : e.status) || 500,
|
|
76
74
|
error
|
|
77
75
|
};
|
|
78
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-client.js","sourceRoot":"","sources":["../../src/http/request-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+CAAyF;AACzF,
|
|
1
|
+
{"version":3,"file":"request-client.js","sourceRoot":"","sources":["../../src/http/request-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+CAAyF;AACzF,kDAA6E;AAE7E;;;GAGG;AACH,MAAqB,aAAc,SAAQ,4BAAc;IACxC,OAAO,CAAE,GAAW,EAAE,OAAiB;;YAChD,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;QACzD,CAAC;KAAA;IAEY,QAAQ,CAAE,GAAW,EAAE,IAAU,EAAE,OAAiB;;YAC7D,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAChE,CAAC;KAAA;IAEY,SAAS,CAAE,GAAW,EAAE,IAAU,EAAE,OAAiB;;YAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QACjE,CAAC;KAAA;IAEY,OAAO,CAAE,GAAW,EAAE,IAAU,EAAE,OAAiB;;YAC5D,OAAO,IAA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
|
|
1
1
|
{
|
|
2
2
|
"name": "@companieshouse/api-sdk-node",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.64",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"analyse-code": "sonar-scanner"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"axios": "^0.21.4",
|
|
20
21
|
"camelcase-keys": "~6.2.2",
|
|
21
|
-
"request": "~2.88.2",
|
|
22
|
-
"request-promise-native": "~1.0.9",
|
|
23
22
|
"snakecase-keys": "~3.2.0",
|
|
24
23
|
"url-search-params-polyfill": "~8.1.1"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
26
|
+
"@types/axios": "^0.14.0",
|
|
27
27
|
"@types/chai": "^4.2.22",
|
|
28
28
|
"@types/chai-as-promised": "^7.1.4",
|
|
29
29
|
"@types/chai-http": "~4.2.0",
|