@trayio/axios
Advanced tools
Comparing version 4.50.0 to 4.51.0
@@ -6,5 +6,9 @@ import * as TE from 'fp-ts/TaskEither'; | ||
import { FileStorage } from '@trayio/commons/file/File'; | ||
type AxiosOptions = { | ||
rejectUnauthorized: boolean; | ||
}; | ||
export declare class AxiosHttpClient implements HttpClient { | ||
private readonly fileStorage; | ||
constructor(fileStorage?: FileStorage); | ||
private readonly axiosOptions; | ||
constructor(fileStorage?: FileStorage, axiosOptions?: AxiosOptions); | ||
execute(method: HttpMethod, url: string, request: HttpRequest): TE.TaskEither<Error, HttpResponse>; | ||
@@ -15,2 +19,3 @@ private axiosErrorToHttpResponse; | ||
} | ||
export {}; | ||
//# sourceMappingURL=AxiosHttpClient.d.ts.map |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -7,2 +30,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
exports.AxiosHttpClient = void 0; | ||
const O = __importStar(require("fp-ts/Option")); | ||
const Http_1 = require("@trayio/commons/http/Http"); | ||
@@ -15,6 +39,9 @@ const Task_1 = require("@trayio/commons/task/Task"); | ||
const BufferExtensions_1 = require("@trayio/commons/buffer/BufferExtensions"); | ||
const function_1 = require("fp-ts/lib/function"); | ||
class AxiosHttpClient { | ||
fileStorage; | ||
constructor(fileStorage = new NodeFsFileStorage_1.NodeFsFileStorage()) { | ||
axiosOptions; | ||
constructor(fileStorage = new NodeFsFileStorage_1.NodeFsFileStorage(), axiosOptions = { rejectUnauthorized: false }) { | ||
this.fileStorage = fileStorage; | ||
this.axiosOptions = axiosOptions; | ||
} | ||
@@ -42,7 +69,10 @@ execute(method, url, request) { | ||
let axiosConfig; | ||
const httpCertificate = (0, function_1.pipe)(request.agent, O.map((agent) => agent), O.chain((agent) => agent.certificate), O.getOrElse(() => ({}))); | ||
// We need a keep-alive heartbeat shorter than 350 seconds to bypass the idle timeout in AWS NAT/LB servers: | ||
// https://repost.aws/knowledge-center/lambda-vpc-timeout | ||
const httpsAgent = new https_1.Agent({ | ||
const axiosHttpsAgent = new https_1.Agent({ | ||
...httpCertificate, | ||
keepAlive: true, | ||
keepAliveMsecs: 42000, | ||
rejectUnauthorized: this.axiosOptions.rejectUnauthorized, | ||
}); | ||
@@ -67,3 +97,3 @@ if (headers['content-type'] && | ||
headers, | ||
httpsAgent, | ||
httpsAgent: axiosHttpsAgent, | ||
params: request.queryString, | ||
@@ -81,3 +111,3 @@ }; | ||
headers, | ||
httpsAgent, | ||
httpsAgent: axiosHttpsAgent, | ||
params: request.queryString, | ||
@@ -84,0 +114,0 @@ }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const HttpClient_abstract_test_1 = require("@trayio/commons/http/HttpClient.abstract.test"); | ||
const NodeFsFileStorage_1 = require("@trayio/commons/file/NodeFsFileStorage"); | ||
const AxiosHttpClient_1 = require("./AxiosHttpClient"); | ||
describe('AxiosHttpClient Tests', () => { | ||
(0, HttpClient_abstract_test_1.httpClientTest)(new AxiosHttpClient_1.AxiosHttpClient()); | ||
(0, HttpClient_abstract_test_1.httpClientTest)(new AxiosHttpClient_1.AxiosHttpClient(new NodeFsFileStorage_1.NodeFsFileStorage(), { rejectUnauthorized: false })); | ||
}); |
{ | ||
"name": "@trayio/axios", | ||
"version": "4.50.0", | ||
"version": "4.51.0", | ||
"description": "Axios extensions and implementations", | ||
@@ -17,3 +17,3 @@ "exports": { | ||
"dependencies": { | ||
"@trayio/commons": "4.50.0", | ||
"@trayio/commons": "4.51.0", | ||
"axios": "1.7.4", | ||
@@ -20,0 +20,0 @@ "form-data": "4.0.0" |
Sorry, the diff of this file is not supported yet
10193
165
+ Added@trayio/commons@4.51.0(transitive)
- Removed@trayio/commons@4.50.0(transitive)
Updated@trayio/commons@4.51.0