@fiado/http-client
Advanced tools
@@ -5,3 +5,3 @@ import { AxiosRequestConfig } from 'axios'; | ||
| /** | ||
| * Obtiene el valor de timeout de la variable de entorno HTTP_CLIENT_REQUEST_TIMEOUT | ||
| * Obtiene el valor de timeout de la variable de entorno HTTP_CLIENT_REQUEST_TIMEOUT_MILISECONDS | ||
| * @returns El valor de timeout en milisegundos o undefined si no está configurado | ||
@@ -13,21 +13,21 @@ */ | ||
| password: string; | ||
| }, extraConfig?: AxiosRequestConfig): Promise<T>; | ||
| }, extraConfig?: AxiosRequestConfig, enableTimeout?: boolean): Promise<T>; | ||
| post<T>(url: string, data?: any, headers?: Record<string, string>, basicAuth?: { | ||
| username: string; | ||
| password: string; | ||
| }): Promise<T>; | ||
| }, enableTimeout?: boolean): Promise<T>; | ||
| put<T>(url: string, data?: any, headers?: Record<string, string>, basicAuth?: { | ||
| username: string; | ||
| password: string; | ||
| }): Promise<T>; | ||
| }, enableTimeout?: boolean): Promise<T>; | ||
| patch<T>(url: string, data?: any, headers?: Record<string, string>, basicAuth?: { | ||
| username: string; | ||
| password: string; | ||
| }): Promise<T>; | ||
| }, enableTimeout?: boolean): Promise<T>; | ||
| delete<T>(url: string, params?: Record<string, any>, headers?: Record<string, string>, basicAuth?: { | ||
| username: string; | ||
| password: string; | ||
| }): Promise<T>; | ||
| }, enableTimeout?: boolean): Promise<T>; | ||
| private getBasicAuthHeaders; | ||
| } | ||
| export default AxiosHttpRequest; |
+11
-11
@@ -17,3 +17,3 @@ "use strict"; | ||
| /** | ||
| * Obtiene el valor de timeout de la variable de entorno HTTP_CLIENT_REQUEST_TIMEOUT | ||
| * Obtiene el valor de timeout de la variable de entorno HTTP_CLIENT_REQUEST_TIMEOUT_MILISECONDS | ||
| * @returns El valor de timeout en milisegundos o undefined si no está configurado | ||
@@ -26,5 +26,5 @@ */ | ||
| } | ||
| async get(url, params = {}, headers = {}, basicAuth, extraConfig) { | ||
| async get(url, params = {}, headers = {}, basicAuth, extraConfig, enableTimeout = false) { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
| const timeout = this.getTimeoutConfig(); | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config = { | ||
@@ -39,5 +39,5 @@ params, | ||
| } | ||
| async post(url, data = {}, headers = {}, basicAuth) { | ||
| async post(url, data = {}, headers = {}, basicAuth, enableTimeout = false) { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
| const timeout = this.getTimeoutConfig(); | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config = { | ||
@@ -50,5 +50,5 @@ headers: { ...headers, ...authHeaders }, | ||
| } | ||
| async put(url, data = {}, headers = {}, basicAuth) { | ||
| async put(url, data = {}, headers = {}, basicAuth, enableTimeout = false) { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
| const timeout = this.getTimeoutConfig(); | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config = { | ||
@@ -61,5 +61,5 @@ headers: { ...headers, ...authHeaders }, | ||
| } | ||
| async patch(url, data = {}, headers = {}, basicAuth) { | ||
| async patch(url, data = {}, headers = {}, basicAuth, enableTimeout = false) { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
| const timeout = this.getTimeoutConfig(); | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config = { | ||
@@ -72,5 +72,5 @@ headers: { ...headers, ...authHeaders }, | ||
| } | ||
| async delete(url, params = {}, headers = {}, basicAuth) { | ||
| async delete(url, params = {}, headers = {}, basicAuth, enableTimeout = false) { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
| const timeout = this.getTimeoutConfig(); | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config = { | ||
@@ -77,0 +77,0 @@ params, |
@@ -6,19 +6,19 @@ import { AxiosRequestConfig } from "axios"; | ||
| password: string; | ||
| }, extraConfig?: AxiosRequestConfig): Promise<T>; | ||
| }, extraConfig?: AxiosRequestConfig, enableTimeout?: boolean): Promise<T>; | ||
| post<T>(url: string, data?: any, headers?: Record<string, string>, basicAuth?: { | ||
| username: string; | ||
| password: string; | ||
| }): Promise<T>; | ||
| }, enableTimeout?: boolean): Promise<T>; | ||
| put<T>(url: string, data?: any, headers?: Record<string, string>, basicAuth?: { | ||
| username: string; | ||
| password: string; | ||
| }): Promise<T>; | ||
| }, enableTimeout?: boolean): Promise<T>; | ||
| patch<T>(url: string, data?: any, headers?: Record<string, string>, basicAuth?: { | ||
| username: string; | ||
| password: string; | ||
| }): Promise<T>; | ||
| }, enableTimeout?: boolean): Promise<T>; | ||
| delete<T>(url: string, params?: Record<string, any>, headers?: Record<string, string>, basicAuth?: { | ||
| username: string; | ||
| password: string; | ||
| }): Promise<T>; | ||
| }, enableTimeout?: boolean): Promise<T>; | ||
| } |
+1
-1
| { | ||
| "name": "@fiado/http-client", | ||
| "version": "1.0.6", | ||
| "version": "1.0.7", | ||
| "description": "Herramienta para realizar solicitudes http", | ||
@@ -5,0 +5,0 @@ "main": "bin/index.js", |
+11
-11
@@ -9,3 +9,3 @@ import axios, {AxiosRequestConfig} from 'axios'; | ||
| /** | ||
| * Obtiene el valor de timeout de la variable de entorno HTTP_CLIENT_REQUEST_TIMEOUT | ||
| * Obtiene el valor de timeout de la variable de entorno HTTP_CLIENT_REQUEST_TIMEOUT_MILISECONDS | ||
| * @returns El valor de timeout en milisegundos o undefined si no está configurado | ||
@@ -22,5 +22,5 @@ */ | ||
| password: string | ||
| }, extraConfig?: AxiosRequestConfig): Promise<T> { | ||
| }, extraConfig?: AxiosRequestConfig, enableTimeout: boolean = false): Promise<T> { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
| const timeout = this.getTimeoutConfig(); | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config: AxiosRequestConfig = { | ||
@@ -39,5 +39,5 @@ params, | ||
| password: string | ||
| }): Promise<T> { | ||
| }, enableTimeout: boolean = false): Promise<T> { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
| const timeout = this.getTimeoutConfig(); | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config: AxiosRequestConfig = { | ||
@@ -54,5 +54,5 @@ headers: {...headers, ...authHeaders}, | ||
| password: string | ||
| }): Promise<T> { | ||
| }, enableTimeout: boolean = false): Promise<T> { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
| const timeout = this.getTimeoutConfig(); | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config: AxiosRequestConfig = { | ||
@@ -69,5 +69,5 @@ headers: {...headers, ...authHeaders}, | ||
| password: string | ||
| }): Promise<T> { | ||
| }, enableTimeout: boolean = false): Promise<T> { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
| const timeout = this.getTimeoutConfig(); | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config: AxiosRequestConfig = { | ||
@@ -84,5 +84,5 @@ headers: {...headers, ...authHeaders}, | ||
| password: string | ||
| }): Promise<T> { | ||
| }, enableTimeout: boolean = false): Promise<T> { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
| const timeout = this.getTimeoutConfig(); | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config: AxiosRequestConfig = { | ||
@@ -89,0 +89,0 @@ params, |
+10
-5
@@ -10,3 +10,4 @@ import {AxiosRequestConfig} from "axios"; | ||
| basicAuth?: { username: string; password: string }, | ||
| extraConfig?: AxiosRequestConfig | ||
| extraConfig?: AxiosRequestConfig, | ||
| enableTimeout?: boolean | ||
| ): Promise<T>; | ||
@@ -18,3 +19,4 @@ | ||
| headers?: Record<string, string>, | ||
| basicAuth?: { username: string; password: string } | ||
| basicAuth?: { username: string; password: string }, | ||
| enableTimeout?: boolean | ||
| ): Promise<T>; | ||
@@ -26,3 +28,4 @@ | ||
| headers?: Record<string, string>, | ||
| basicAuth?: { username: string; password: string } | ||
| basicAuth?: { username: string; password: string }, | ||
| enableTimeout?: boolean | ||
| ): Promise<T>; | ||
@@ -34,3 +37,4 @@ | ||
| headers?: Record<string, string>, | ||
| basicAuth?: { username: string; password: string } | ||
| basicAuth?: { username: string; password: string }, | ||
| enableTimeout?: boolean | ||
| ): Promise<T>; | ||
@@ -42,4 +46,5 @@ | ||
| headers?: Record<string, string>, | ||
| basicAuth?: { username: string; password: string } | ||
| basicAuth?: { username: string; password: string }, | ||
| enableTimeout?: boolean | ||
| ): Promise<T>; | ||
| } |
16411
6.53%295
1.72%