@fiado/http-client
Advanced tools
@@ -16,17 +16,17 @@ import { AxiosRequestConfig } from 'axios'; | ||
| password: string; | ||
| }, enableTimeout?: boolean): Promise<T>; | ||
| }, enableTimeout?: boolean, extraConfig?: AxiosRequestConfig): Promise<T>; | ||
| put<T>(url: string, data?: any, headers?: Record<string, string>, basicAuth?: { | ||
| username: string; | ||
| password: string; | ||
| }, enableTimeout?: boolean): Promise<T>; | ||
| }, enableTimeout?: boolean, extraConfig?: AxiosRequestConfig): Promise<T>; | ||
| patch<T>(url: string, data?: any, headers?: Record<string, string>, basicAuth?: { | ||
| username: string; | ||
| password: string; | ||
| }, enableTimeout?: boolean): Promise<T>; | ||
| }, enableTimeout?: boolean, extraConfig?: AxiosRequestConfig): Promise<T>; | ||
| delete<T>(url: string, params?: Record<string, any>, headers?: Record<string, string>, basicAuth?: { | ||
| username: string; | ||
| password: string; | ||
| }, enableTimeout?: boolean): Promise<T>; | ||
| }, enableTimeout?: boolean, extraConfig?: AxiosRequestConfig): Promise<T>; | ||
| private getBasicAuthHeaders; | ||
| } | ||
| export default AxiosHttpRequest; |
@@ -37,3 +37,3 @@ "use strict"; | ||
| } | ||
| async post(url, data = {}, headers = {}, basicAuth, enableTimeout = false) { | ||
| async post(url, data = {}, headers = {}, basicAuth, enableTimeout = false, extraConfig) { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
@@ -43,3 +43,4 @@ const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| headers: { ...headers, ...authHeaders }, | ||
| ...(timeout !== undefined && { timeout }) | ||
| ...(timeout !== undefined && { timeout }), | ||
| ...extraConfig | ||
| }; | ||
@@ -49,3 +50,3 @@ const response = await axios_1.default.post(url, data, config); | ||
| } | ||
| async put(url, data = {}, headers = {}, basicAuth, enableTimeout = false) { | ||
| async put(url, data = {}, headers = {}, basicAuth, enableTimeout = false, extraConfig) { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
@@ -55,3 +56,4 @@ const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| headers: { ...headers, ...authHeaders }, | ||
| ...(timeout !== undefined && { timeout }) | ||
| ...(timeout !== undefined && { timeout }), | ||
| ...extraConfig | ||
| }; | ||
@@ -61,3 +63,3 @@ const response = await axios_1.default.put(url, data, config); | ||
| } | ||
| async patch(url, data = {}, headers = {}, basicAuth, enableTimeout = false) { | ||
| async patch(url, data = {}, headers = {}, basicAuth, enableTimeout = false, extraConfig) { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
@@ -67,3 +69,4 @@ const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| headers: { ...headers, ...authHeaders }, | ||
| ...(timeout !== undefined && { timeout }) | ||
| ...(timeout !== undefined && { timeout }), | ||
| ...extraConfig | ||
| }; | ||
@@ -73,9 +76,9 @@ const response = await axios_1.default.patch(url, data, config); | ||
| } | ||
| async delete(url, params = {}, headers = {}, basicAuth, enableTimeout = false) { | ||
| async delete(url, params = {}, headers = {}, basicAuth, enableTimeout = false, extraConfig) { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config = { | ||
| params, | ||
| headers: { ...headers, ...authHeaders }, | ||
| ...(timeout !== undefined && { timeout }) | ||
| ...(timeout !== undefined && { timeout }), | ||
| ...extraConfig | ||
| }; | ||
@@ -82,0 +85,0 @@ const response = await axios_1.default.delete(url, config); |
+1
-1
| { | ||
| "name": "@fiado/http-client", | ||
| "version": "1.0.7", | ||
| "version": "1.0.8", | ||
| "description": "Herramienta para realizar solicitudes http", | ||
@@ -5,0 +5,0 @@ "main": "bin/index.js", |
+80
-30
| import axios, {AxiosRequestConfig} from 'axios'; | ||
| import {IHttpRequest} from './IHttpRequest'; | ||
| import https from 'https'; | ||
| import {injectable} from 'inversify'; | ||
@@ -18,6 +19,14 @@ | ||
| async get<T>(url: string, params: Record<string, any> = {}, headers: Record<string, string> = {}, basicAuth?: { | ||
| username: string, | ||
| password: string | ||
| }, extraConfig?: AxiosRequestConfig, enableTimeout: boolean = false): Promise<T> { | ||
| async get<T>( | ||
| url: string, | ||
| params: Record<string, any> = {}, | ||
| headers: Record<string, string> = {}, | ||
| basicAuth?: { | ||
| username: string, | ||
| password: string | ||
| }, | ||
| extraConfig?: AxiosRequestConfig, | ||
| enableTimeout: boolean = false | ||
| ): Promise<T> { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
@@ -35,12 +44,23 @@ const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| async post<T>(url: string, data: any = {}, headers: Record<string, string> = {}, basicAuth?: { | ||
| username: string, | ||
| password: string | ||
| }, enableTimeout: boolean = false): Promise<T> { | ||
| async post<T>( | ||
| url: string, | ||
| data: any = {}, | ||
| headers: Record<string, string> = {}, | ||
| basicAuth?: { | ||
| username: string, | ||
| password: string | ||
| }, | ||
| enableTimeout: boolean = false, | ||
| extraConfig?: AxiosRequestConfig, | ||
| ): Promise<T> { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config: AxiosRequestConfig = { | ||
| const config: AxiosRequestConfig = { | ||
| headers: {...headers, ...authHeaders}, | ||
| ...(timeout !== undefined && { timeout }) | ||
| ...(timeout !== undefined && { timeout }), | ||
| ...extraConfig | ||
| }; | ||
| const response = await axios.post<T>(url, data, config); | ||
@@ -50,11 +70,21 @@ return response.data; | ||
| async put<T>(url: string, data: any = {}, headers: Record<string, string> = {}, basicAuth?: { | ||
| username: string, | ||
| password: string | ||
| }, enableTimeout: boolean = false): Promise<T> { | ||
| async put<T>( | ||
| url: string, | ||
| data: any = {}, | ||
| headers: Record<string, string> = {}, | ||
| basicAuth?: { | ||
| username: string, | ||
| password: string | ||
| }, | ||
| enableTimeout: boolean = false, | ||
| extraConfig?: AxiosRequestConfig, | ||
| ): Promise<T> { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config: AxiosRequestConfig = { | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config: AxiosRequestConfig = { | ||
| headers: {...headers, ...authHeaders}, | ||
| ...(timeout !== undefined && { timeout }) | ||
| ...(timeout !== undefined && { timeout }), | ||
| ...extraConfig | ||
| }; | ||
@@ -65,11 +95,20 @@ const response = await axios.put<T>(url, data, config); | ||
| async patch<T>(url: string, data: any = {}, headers: Record<string, string> = {}, basicAuth?: { | ||
| username: string, | ||
| password: string | ||
| }, enableTimeout: boolean = false): Promise<T> { | ||
| async patch<T>( | ||
| url: string, | ||
| data: any = {}, | ||
| headers: Record<string, string> = {}, | ||
| basicAuth?: { | ||
| username: string, | ||
| password: string | ||
| }, enableTimeout: boolean = false, | ||
| extraConfig?: AxiosRequestConfig, | ||
| ): Promise<T> { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config: AxiosRequestConfig = { | ||
| const config: AxiosRequestConfig = { | ||
| headers: {...headers, ...authHeaders}, | ||
| ...(timeout !== undefined && { timeout }) | ||
| ...(timeout !== undefined && { timeout }), | ||
| ...extraConfig | ||
| }; | ||
@@ -80,13 +119,24 @@ const response = await axios.patch<T>(url, data, config); | ||
| async delete<T>(url: string, params: Record<string, any> = {}, headers: Record<string, string> = {}, basicAuth?: { | ||
| username: string, | ||
| password: string | ||
| }, enableTimeout: boolean = false): Promise<T> { | ||
| async delete<T>( | ||
| url: string, | ||
| params: Record<string, any> = {}, | ||
| headers: Record<string, string> = {}, | ||
| basicAuth?: { | ||
| username: string, | ||
| password: string | ||
| }, | ||
| enableTimeout: boolean = false, | ||
| extraConfig?: AxiosRequestConfig, | ||
| ): Promise<T> { | ||
| const authHeaders = basicAuth ? this.getBasicAuthHeaders(basicAuth.username, basicAuth.password) : {}; | ||
| const timeout = enableTimeout ? this.getTimeoutConfig() : undefined; | ||
| const config: AxiosRequestConfig = { | ||
| params, | ||
| const config: AxiosRequestConfig = { | ||
| params, | ||
| headers: {...headers, ...authHeaders}, | ||
| ...(timeout !== undefined && { timeout }) | ||
| ...(timeout !== undefined && { timeout }), | ||
| ...extraConfig | ||
| }; | ||
| const response = await axios.delete<T>(url, config); | ||
@@ -93,0 +143,0 @@ return response.data; |
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="accountSettings"> | ||
| <option name="activeRegion" value="us-east-1" /> | ||
| <option name="recentlyUsedRegions"> | ||
| <list> | ||
| <option value="us-east-1" /> | ||
| </list> | ||
| </option> | ||
| </component> | ||
| </project> |
Sorry, the diff of this file is not supported yet
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="ProjectModuleManager"> | ||
| <modules> | ||
| <module fileurl="file://$PROJECT_DIR$/.idea/fiado-http-client.iml" filepath="$PROJECT_DIR$/.idea/fiado-http-client.iml" /> | ||
| </modules> | ||
| </component> | ||
| </project> |
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="VcsDirectoryMappings"> | ||
| <mapping directory="" vcs="Git" /> | ||
| </component> | ||
| </project> |
Network access
Supply chain riskThis module accesses the network.
337
14.24%16167
-1.49%11
-26.67%1
Infinity%