@trayio/axios 4.50.0 → 4.52.0
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.
|
@@ -3,12 +3,17 @@ import { HttpClient } from '@trayio/commons/http/HttpClient';
|
|
|
3
3
|
import { HttpMethod, HttpRequest, HttpResponse } from '@trayio/commons/http/Http';
|
|
4
4
|
import FormData = require('form-data');
|
|
5
5
|
import { FileStorage } from '@trayio/commons/file/File';
|
|
6
|
+
type AxiosOptions = {
|
|
7
|
+
rejectUnauthorized: boolean;
|
|
8
|
+
};
|
|
6
9
|
export declare class AxiosHttpClient implements HttpClient {
|
|
7
10
|
private readonly fileStorage;
|
|
8
|
-
|
|
11
|
+
private readonly axiosOptions;
|
|
12
|
+
constructor(fileStorage?: FileStorage, axiosOptions?: AxiosOptions);
|
|
9
13
|
execute(method: HttpMethod, url: string, request: HttpRequest): TE.TaskEither<Error, HttpResponse>;
|
|
10
14
|
private axiosErrorToHttpResponse;
|
|
11
15
|
private axiosResponseToHttpResponse;
|
|
12
16
|
appendFields: (formData: FormData) => (fields: Record<string, string>) => FormData;
|
|
13
17
|
}
|
|
18
|
+
export {};
|
|
14
19
|
//# sourceMappingURL=AxiosHttpClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosHttpClient.d.ts","sourceRoot":"","sources":["../../src/http/AxiosHttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"AxiosHttpClient.d.ts","sourceRoot":"","sources":["../../src/http/AxiosHttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAEN,UAAU,EACV,WAAW,EAEX,YAAY,EAEZ,MAAM,2BAA2B,CAAC;AAInC,OAAO,QAAQ,GAAG,QAAQ,WAAW,CAAC,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAMxD,KAAK,YAAY,GAAG;IACnB,kBAAkB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,qBAAa,eAAgB,YAAW,UAAU;IAEhD,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,WAAW,GAAE,WAAqC,EAClD,YAAY,GAAE,YAA4C;IAG5E,OAAO,CACN,MAAM,EAAE,UAAU,EAClB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,GAClB,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,YAAY,CAAC;IAoGrC,OAAO,CAAC,wBAAwB;IAchC,OAAO,CAAC,2BAA2B;IAUnC,YAAY,aAAc,QAAQ,cAAc,OAAO,MAAM,EAAE,MAAM,CAAC,cAKpE;CACF"}
|
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.AxiosHttpClient = void 0;
|
|
30
|
+
const O = __importStar(require("fp-ts/Option"));
|
|
7
31
|
const Http_1 = require("@trayio/commons/http/Http");
|
|
8
32
|
const Task_1 = require("@trayio/commons/task/Task");
|
|
9
33
|
const axios_1 = __importDefault(require("axios"));
|
|
@@ -11,10 +35,13 @@ const https_1 = require("https");
|
|
|
11
35
|
const FormData = require("form-data");
|
|
12
36
|
const NodeFsFileStorage_1 = require("@trayio/commons/file/NodeFsFileStorage");
|
|
13
37
|
const BufferExtensions_1 = require("@trayio/commons/buffer/BufferExtensions");
|
|
38
|
+
const function_1 = require("fp-ts/lib/function");
|
|
14
39
|
class AxiosHttpClient {
|
|
15
40
|
fileStorage;
|
|
16
|
-
|
|
41
|
+
axiosOptions;
|
|
42
|
+
constructor(fileStorage = new NodeFsFileStorage_1.NodeFsFileStorage(), axiosOptions = { rejectUnauthorized: false }) {
|
|
17
43
|
this.fileStorage = fileStorage;
|
|
44
|
+
this.axiosOptions = axiosOptions;
|
|
18
45
|
}
|
|
19
46
|
execute(method, url, request) {
|
|
20
47
|
/*
|
|
@@ -37,11 +64,14 @@ class AxiosHttpClient {
|
|
|
37
64
|
};
|
|
38
65
|
}, {});
|
|
39
66
|
let axiosConfig;
|
|
67
|
+
const httpCertificate = (0, function_1.pipe)(request.agent, O.map((agent) => agent), O.chain((agent) => agent.certificate), O.getOrElse(() => ({})));
|
|
40
68
|
// We need a keep-alive heartbeat shorter than 350 seconds to bypass the idle timeout in AWS NAT/LB servers:
|
|
41
69
|
// https://repost.aws/knowledge-center/lambda-vpc-timeout
|
|
42
|
-
const
|
|
70
|
+
const axiosHttpsAgent = new https_1.Agent({
|
|
71
|
+
...httpCertificate,
|
|
43
72
|
keepAlive: true,
|
|
44
73
|
keepAliveMsecs: 42000,
|
|
74
|
+
rejectUnauthorized: this.axiosOptions.rejectUnauthorized,
|
|
45
75
|
});
|
|
46
76
|
if (headers['content-type'] &&
|
|
47
77
|
headers['content-type'].includes(Http_1.HttpContentType.MultipartRequestBody)) {
|
|
@@ -61,7 +91,7 @@ class AxiosHttpClient {
|
|
|
61
91
|
data: formData,
|
|
62
92
|
responseType: 'stream',
|
|
63
93
|
headers,
|
|
64
|
-
httpsAgent,
|
|
94
|
+
httpsAgent: axiosHttpsAgent,
|
|
65
95
|
params: request.queryString,
|
|
66
96
|
};
|
|
67
97
|
return (0, Task_1.createTaskEitherFromPromiseWithSimpleError)(() => (0, axios_1.default)(axiosConfig)
|
|
@@ -74,7 +104,7 @@ class AxiosHttpClient {
|
|
|
74
104
|
data: request.body,
|
|
75
105
|
responseType: 'stream',
|
|
76
106
|
headers,
|
|
77
|
-
httpsAgent,
|
|
107
|
+
httpsAgent: axiosHttpsAgent,
|
|
78
108
|
params: request.queryString,
|
|
79
109
|
};
|
|
80
110
|
return (0, Task_1.createTaskEitherFromPromiseWithSimpleError)(() => (0, axios_1.default)(axiosConfig)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const HttpClient_abstract_test_1 = require("@trayio/commons/http/HttpClient.abstract.test");
|
|
4
|
+
const NodeFsFileStorage_1 = require("@trayio/commons/file/NodeFsFileStorage");
|
|
4
5
|
const AxiosHttpClient_1 = require("./AxiosHttpClient");
|
|
5
6
|
describe('AxiosHttpClient Tests', () => {
|
|
6
|
-
(0, HttpClient_abstract_test_1.httpClientTest)(new AxiosHttpClient_1.AxiosHttpClient());
|
|
7
|
+
(0, HttpClient_abstract_test_1.httpClientTest)(new AxiosHttpClient_1.AxiosHttpClient(new NodeFsFileStorage_1.NodeFsFileStorage(), { rejectUnauthorized: false }));
|
|
7
8
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/axios",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.52.0",
|
|
4
4
|
"description": "Axios extensions and implementations",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": "./dist/*.js"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@trayio/commons": "4.
|
|
17
|
+
"@trayio/commons": "4.52.0",
|
|
18
18
|
"axios": "1.7.4",
|
|
19
19
|
"form-data": "4.0.0"
|
|
20
20
|
},
|