@adatechnology/http-client 0.0.1
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.
- package/CHANGELOG.md +7 -0
- package/README.md +596 -0
- package/dist/http.interface.js +27 -0
- package/dist/http.module.js +37 -0
- package/dist/http.provider.js +137 -0
- package/dist/http.token.js +6 -0
- package/dist/implementations/axios/axios.http.module.js +41 -0
- package/dist/implementations/axios/axios.http.provider.js +424 -0
- package/dist/implementations/axios/axios.http.token.js +4 -0
- package/dist/implementations/http.implementation.module.js +20 -0
- package/dist/index.js +11 -0
- package/dist/types/http.interface.d.ts +175 -0
- package/dist/types/http.module.d.ts +9 -0
- package/dist/types/http.provider.d.ts +43 -0
- package/dist/types/http.token.d.ts +3 -0
- package/dist/types/implementations/axios/axios.http.module.d.ts +5 -0
- package/dist/types/implementations/axios/axios.http.provider.d.ts +226 -0
- package/dist/types/implementations/axios/axios.http.token.d.ts +1 -0
- package/dist/types/implementations/http.implementation.module.d.ts +2 -0
- package/dist/types/index.d.ts +4 -0
- package/package.json +19 -0
- package/src/http.interface.ts +259 -0
- package/src/http.module.ts +27 -0
- package/src/http.provider.ts +219 -0
- package/src/http.token.ts +3 -0
- package/src/implementations/axios/axios.http.module.ts +33 -0
- package/src/implementations/axios/axios.http.provider.ts +603 -0
- package/src/implementations/axios/axios.http.token.ts +1 -0
- package/src/implementations/http.implementation.module.ts +9 -0
- package/src/index.ts +8 -0
- package/tsconfig.json +16 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
/**
|
|
3
|
+
* HTTP methods supported
|
|
4
|
+
*/
|
|
5
|
+
export declare enum HttpMethod {
|
|
6
|
+
GET = "GET",
|
|
7
|
+
POST = "POST",
|
|
8
|
+
PUT = "PUT",
|
|
9
|
+
PATCH = "PATCH",
|
|
10
|
+
DELETE = "DELETE",
|
|
11
|
+
HEAD = "HEAD",
|
|
12
|
+
OPTIONS = "OPTIONS"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Content types for HTTP requests
|
|
16
|
+
*/
|
|
17
|
+
export declare enum ContentType {
|
|
18
|
+
JSON = "application/json",
|
|
19
|
+
FORM_URLENCODED = "application/x-www-form-urlencoded",
|
|
20
|
+
FORM_DATA = "multipart/form-data",
|
|
21
|
+
TEXT = "text/plain",
|
|
22
|
+
XML = "application/xml"
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* HTTP request configuration
|
|
26
|
+
*/
|
|
27
|
+
export interface HttpRequestConfig {
|
|
28
|
+
url: string;
|
|
29
|
+
method?: HttpMethod;
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
params?: Record<string, any>;
|
|
32
|
+
data?: any;
|
|
33
|
+
timeout?: number;
|
|
34
|
+
contentType?: ContentType;
|
|
35
|
+
responseType?: "json" | "text" | "blob" | "arraybuffer";
|
|
36
|
+
withCredentials?: boolean;
|
|
37
|
+
retryAttempts?: number;
|
|
38
|
+
retryDelay?: number;
|
|
39
|
+
cache?: boolean;
|
|
40
|
+
cacheTtl?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* HTTP response structure
|
|
44
|
+
*/
|
|
45
|
+
export interface HttpResponse<T = any> {
|
|
46
|
+
data: T;
|
|
47
|
+
status: number;
|
|
48
|
+
statusText: string;
|
|
49
|
+
headers: Record<string, string>;
|
|
50
|
+
config: HttpRequestConfig;
|
|
51
|
+
request?: any;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* HTTP error structure
|
|
55
|
+
*/
|
|
56
|
+
export interface HttpError extends Error {
|
|
57
|
+
config: HttpRequestConfig;
|
|
58
|
+
response?: HttpResponse;
|
|
59
|
+
status?: number;
|
|
60
|
+
statusText?: string;
|
|
61
|
+
isNetworkError?: boolean;
|
|
62
|
+
isTimeout?: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Error interceptor function
|
|
66
|
+
*/
|
|
67
|
+
export type ErrorInterceptor = (error: any) => any;
|
|
68
|
+
/**
|
|
69
|
+
* HTTP provider interface
|
|
70
|
+
*/
|
|
71
|
+
export interface HttpProviderInterface {
|
|
72
|
+
/**
|
|
73
|
+
* Make a GET request
|
|
74
|
+
*/
|
|
75
|
+
get<T = any>(url: string, config?: Omit<HttpRequestConfig, "url" | "method">): Promise<HttpResponse<T>>;
|
|
76
|
+
/**
|
|
77
|
+
* Make a POST request
|
|
78
|
+
*/
|
|
79
|
+
post<T = any>(url: string, data?: any, config?: Omit<HttpRequestConfig, "url" | "method" | "data">): Promise<HttpResponse<T>>;
|
|
80
|
+
/**
|
|
81
|
+
* Make a PUT request
|
|
82
|
+
*/
|
|
83
|
+
put<T = any>(url: string, data?: any, config?: Omit<HttpRequestConfig, "url" | "method" | "data">): Promise<HttpResponse<T>>;
|
|
84
|
+
/**
|
|
85
|
+
* Make a PATCH request
|
|
86
|
+
*/
|
|
87
|
+
patch<T = any>(url: string, data?: any, config?: Omit<HttpRequestConfig, "url" | "method" | "data">): Promise<HttpResponse<T>>;
|
|
88
|
+
/**
|
|
89
|
+
* Make a DELETE request
|
|
90
|
+
*/
|
|
91
|
+
delete<T = any>(url: string, config?: Omit<HttpRequestConfig, "url" | "method">): Promise<HttpResponse<T>>;
|
|
92
|
+
/**
|
|
93
|
+
* Make a HEAD request
|
|
94
|
+
*/
|
|
95
|
+
head<T = any>(url: string, config?: Omit<HttpRequestConfig, "url" | "method">): Promise<HttpResponse<T>>;
|
|
96
|
+
/**
|
|
97
|
+
* Make an OPTIONS request
|
|
98
|
+
*/
|
|
99
|
+
options<T = any>(url: string, config?: Omit<HttpRequestConfig, "url" | "method">): Promise<HttpResponse<T>>;
|
|
100
|
+
/**
|
|
101
|
+
* Make a generic HTTP request
|
|
102
|
+
*/
|
|
103
|
+
request<T = any>(config: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
104
|
+
/**
|
|
105
|
+
* Set global headers
|
|
106
|
+
*/
|
|
107
|
+
setGlobalHeader(key: string, value: string): void;
|
|
108
|
+
/**
|
|
109
|
+
* Remove global header
|
|
110
|
+
*/
|
|
111
|
+
removeGlobalHeader(key: string): void;
|
|
112
|
+
/**
|
|
113
|
+
* Get global headers
|
|
114
|
+
*/
|
|
115
|
+
getGlobalHeaders(): Record<string, string>;
|
|
116
|
+
/**
|
|
117
|
+
* Set base URL for all requests
|
|
118
|
+
*/
|
|
119
|
+
setBaseUrl(baseUrl: string): void;
|
|
120
|
+
/**
|
|
121
|
+
* Get current base URL
|
|
122
|
+
*/
|
|
123
|
+
getBaseUrl(): string;
|
|
124
|
+
/**
|
|
125
|
+
* Set default timeout
|
|
126
|
+
*/
|
|
127
|
+
setDefaultTimeout(timeout: number): void;
|
|
128
|
+
/**
|
|
129
|
+
* Add error interceptor
|
|
130
|
+
*/
|
|
131
|
+
addErrorInterceptor(interceptor: ErrorInterceptor): number;
|
|
132
|
+
/**
|
|
133
|
+
* Remove error interceptor
|
|
134
|
+
*/
|
|
135
|
+
removeErrorInterceptor(id: number): void;
|
|
136
|
+
/**
|
|
137
|
+
* Clear cache for a specific key or all cache
|
|
138
|
+
*/
|
|
139
|
+
clearCache(key?: string): void;
|
|
140
|
+
/**
|
|
141
|
+
* Set authorization token
|
|
142
|
+
*/
|
|
143
|
+
setAuthToken(token: string, type?: string): void;
|
|
144
|
+
/**
|
|
145
|
+
* Clear authorization token
|
|
146
|
+
*/
|
|
147
|
+
clearAuthToken(): void;
|
|
148
|
+
/**
|
|
149
|
+
* Add request interceptor
|
|
150
|
+
*/
|
|
151
|
+
addRequestInterceptor(onFulfilled: (config: any) => any, onRejected?: (error: any) => any): number;
|
|
152
|
+
/**
|
|
153
|
+
* Remove request interceptor by id
|
|
154
|
+
*/
|
|
155
|
+
removeRequestInterceptor(id: number): void;
|
|
156
|
+
/**
|
|
157
|
+
* Add response interceptor
|
|
158
|
+
*/
|
|
159
|
+
addResponseInterceptor(onFulfilled: (response: any) => any, onRejected?: (error: any) => any): number;
|
|
160
|
+
/**
|
|
161
|
+
* Remove response interceptor by id
|
|
162
|
+
*/
|
|
163
|
+
removeResponseInterceptor(id: number): void;
|
|
164
|
+
/**
|
|
165
|
+
* Observable version for reactive programming
|
|
166
|
+
*/
|
|
167
|
+
get$<T = any>(url: string, config?: Omit<HttpRequestConfig, "url" | "method">): Observable<HttpResponse<T>>;
|
|
168
|
+
post$<T = any>(url: string, data?: any, config?: Omit<HttpRequestConfig, "url" | "method" | "data">): Observable<HttpResponse<T>>;
|
|
169
|
+
put$<T = any>(url: string, data?: any, config?: Omit<HttpRequestConfig, "url" | "method" | "data">): Observable<HttpResponse<T>>;
|
|
170
|
+
patch$<T = any>(url: string, data?: any, config?: Omit<HttpRequestConfig, "url" | "method" | "data">): Observable<HttpResponse<T>>;
|
|
171
|
+
delete$<T = any>(url: string, config?: Omit<HttpRequestConfig, "url" | "method">): Observable<HttpResponse<T>>;
|
|
172
|
+
head$<T = any>(url: string, config?: Omit<HttpRequestConfig, "url" | "method">): Observable<HttpResponse<T>>;
|
|
173
|
+
options$<T = any>(url: string, config?: Omit<HttpRequestConfig, "url" | "method">): Observable<HttpResponse<T>>;
|
|
174
|
+
request$<T = any>(config: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
175
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DynamicModule } from "@nestjs/common";
|
|
2
|
+
import { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
3
|
+
export declare class HttpModule {
|
|
4
|
+
/**
|
|
5
|
+
* Configure HttpModule with an Axios instance or AxiosRequestConfig.
|
|
6
|
+
* This will import the implementation-specific module (currently Axios).
|
|
7
|
+
*/
|
|
8
|
+
static forRoot(config?: AxiosRequestConfig | AxiosInstance): DynamicModule;
|
|
9
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { ErrorInterceptor, HttpProviderInterface, HttpRequestConfig, HttpResponse } from "./http.interface";
|
|
3
|
+
import type { AxiosHttpProviderInterface } from "./implementations/axios/axios.http.provider";
|
|
4
|
+
export declare class HttpProvider implements HttpProviderInterface {
|
|
5
|
+
private readonly axiosHttpProvider;
|
|
6
|
+
constructor(axiosHttpProvider: AxiosHttpProviderInterface);
|
|
7
|
+
/**
|
|
8
|
+
* Expose underlying axios instance when available from the axios provider implementation.
|
|
9
|
+
* This is intentionally typed as unknown/any to avoid leaking implementation details.
|
|
10
|
+
*/
|
|
11
|
+
getAxiosInstance(): any | undefined;
|
|
12
|
+
get<T>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
13
|
+
get$<T>(url: string, config?: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
14
|
+
post<T>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
15
|
+
post$<T>(url: string, data?: any, config?: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
16
|
+
put<T>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
17
|
+
put$<T>(url: string, data?: any, config?: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
18
|
+
patch<T>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
19
|
+
patch$<T>(url: string, data?: any, config?: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
20
|
+
delete<T>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
21
|
+
delete$<T>(url: string, config?: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
22
|
+
head<T>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
23
|
+
head$<T>(url: string, config?: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
24
|
+
options<T>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
25
|
+
options$<T>(url: string, config?: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
26
|
+
request<T>(config: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
27
|
+
request$<T>(config: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
28
|
+
setGlobalHeader(key: string, value: string): void;
|
|
29
|
+
removeGlobalHeader(key: string): void;
|
|
30
|
+
getGlobalHeaders(): Record<string, string>;
|
|
31
|
+
setBaseUrl(baseUrl: string): void;
|
|
32
|
+
getBaseUrl(): string;
|
|
33
|
+
setDefaultTimeout(timeout: number): void;
|
|
34
|
+
addErrorInterceptor(interceptor: ErrorInterceptor): number;
|
|
35
|
+
removeErrorInterceptor(id: number): void;
|
|
36
|
+
clearCache(key?: string): void;
|
|
37
|
+
setAuthToken(token: string, type?: string): void;
|
|
38
|
+
clearAuthToken(): void;
|
|
39
|
+
addRequestInterceptor(onFulfilled: (config: any) => any, onRejected?: (error: any) => any): number;
|
|
40
|
+
removeRequestInterceptor(id: number): void;
|
|
41
|
+
addResponseInterceptor(onFulfilled: (response: any) => any, onRejected?: (error: any) => any): number;
|
|
42
|
+
removeResponseInterceptor(id: number): void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
import { ErrorInterceptor, HttpProviderInterface, HttpRequestConfig, HttpResponse } from "../../http.interface";
|
|
4
|
+
/**
|
|
5
|
+
* Interface for Axios HTTP Provider
|
|
6
|
+
*/
|
|
7
|
+
export interface AxiosHttpProviderInterface extends HttpProviderInterface {
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Axios-based implementation of the HTTP provider interface.
|
|
11
|
+
* Provides HTTP client functionality with both Promise and Observable APIs,
|
|
12
|
+
* plus basic caching capabilities.
|
|
13
|
+
*/
|
|
14
|
+
export declare class AxiosHttpProvider implements AxiosHttpProviderInterface {
|
|
15
|
+
private axiosInstance;
|
|
16
|
+
private errorInterceptors;
|
|
17
|
+
private nextErrorInterceptorId;
|
|
18
|
+
private requestInterceptorIds;
|
|
19
|
+
private responseInterceptorIds;
|
|
20
|
+
private cache;
|
|
21
|
+
private cacheCleanupInterval?;
|
|
22
|
+
constructor(axiosInstance?: AxiosInstance);
|
|
23
|
+
/**
|
|
24
|
+
* Starts automatic cache cleanup
|
|
25
|
+
*/
|
|
26
|
+
private startCacheCleanup;
|
|
27
|
+
/**
|
|
28
|
+
* Stops automatic cache cleanup
|
|
29
|
+
*/
|
|
30
|
+
private stopCacheCleanup;
|
|
31
|
+
/**
|
|
32
|
+
* Cleans up expired cache entries
|
|
33
|
+
*/
|
|
34
|
+
private cleanupExpiredCache;
|
|
35
|
+
/**
|
|
36
|
+
* Generates a cache key from URL and config
|
|
37
|
+
*/
|
|
38
|
+
private generateCacheKey;
|
|
39
|
+
/**
|
|
40
|
+
* Gets cached data if valid
|
|
41
|
+
*/
|
|
42
|
+
private getCached;
|
|
43
|
+
/**
|
|
44
|
+
* Sets data in cache
|
|
45
|
+
*/
|
|
46
|
+
private setCache;
|
|
47
|
+
/**
|
|
48
|
+
* Clears cache for a specific key or all cache
|
|
49
|
+
*/
|
|
50
|
+
clearCache(key?: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Gets cache statistics
|
|
53
|
+
*/
|
|
54
|
+
getCacheStats(): {
|
|
55
|
+
size: number;
|
|
56
|
+
keys: string[];
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Sets a global header that will be included in all requests.
|
|
60
|
+
*/
|
|
61
|
+
setGlobalHeader(key: string, value: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* Removes a global header.
|
|
64
|
+
*/
|
|
65
|
+
removeGlobalHeader(key: string): void;
|
|
66
|
+
/**
|
|
67
|
+
* Gets all global headers currently set.
|
|
68
|
+
*/
|
|
69
|
+
getGlobalHeaders(): Record<string, string>;
|
|
70
|
+
/**
|
|
71
|
+
* Sets the base URL for all requests.
|
|
72
|
+
*/
|
|
73
|
+
setBaseUrl(baseUrl: string): void;
|
|
74
|
+
/**
|
|
75
|
+
* Gets the current base URL.
|
|
76
|
+
*/
|
|
77
|
+
getBaseUrl(): string;
|
|
78
|
+
/**
|
|
79
|
+
* Sets the default timeout for all requests.
|
|
80
|
+
*/
|
|
81
|
+
setDefaultTimeout(timeout: number): void;
|
|
82
|
+
/**
|
|
83
|
+
* Adds an error interceptor for handling errors globally.
|
|
84
|
+
*/
|
|
85
|
+
addErrorInterceptor(interceptor: ErrorInterceptor): number;
|
|
86
|
+
/**
|
|
87
|
+
* Adds a request interceptor to the underlying Axios instance.
|
|
88
|
+
*/
|
|
89
|
+
addRequestInterceptor(onFulfilled: (config: any) => any, onRejected?: (error: any) => any): number;
|
|
90
|
+
/**
|
|
91
|
+
* Removes a request interceptor by id.
|
|
92
|
+
*/
|
|
93
|
+
removeRequestInterceptor(id: number): void;
|
|
94
|
+
/**
|
|
95
|
+
* Adds a response interceptor to the underlying Axios instance.
|
|
96
|
+
*/
|
|
97
|
+
addResponseInterceptor(onFulfilled: (res: any) => any, onRejected?: (error: any) => any): number;
|
|
98
|
+
/**
|
|
99
|
+
* Removes a response interceptor by id.
|
|
100
|
+
*/
|
|
101
|
+
removeResponseInterceptor(id: number): void;
|
|
102
|
+
/**
|
|
103
|
+
* Removes an error interceptor by its ID.
|
|
104
|
+
*/
|
|
105
|
+
removeErrorInterceptor(id: number): void;
|
|
106
|
+
/**
|
|
107
|
+
* Performs a GET request to the specified URL.
|
|
108
|
+
*/
|
|
109
|
+
get<T>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
110
|
+
/**
|
|
111
|
+
* Internal method to perform the actual GET request.
|
|
112
|
+
*/
|
|
113
|
+
private performGet;
|
|
114
|
+
/**
|
|
115
|
+
* Performs a GET request and returns an Observable.
|
|
116
|
+
*/
|
|
117
|
+
get$<T>(url: string, config?: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
118
|
+
/**
|
|
119
|
+
* Performs a POST request.
|
|
120
|
+
*/
|
|
121
|
+
post<T>(url: string, data?: unknown, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
122
|
+
/**
|
|
123
|
+
* Internal method to perform the actual POST request.
|
|
124
|
+
*/
|
|
125
|
+
private performPost;
|
|
126
|
+
/**
|
|
127
|
+
* Performs a POST request and returns an Observable.
|
|
128
|
+
*/
|
|
129
|
+
post$<T>(url: string, data?: unknown, config?: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
130
|
+
/**
|
|
131
|
+
* Performs a PUT request.
|
|
132
|
+
*/
|
|
133
|
+
put<T>(url: string, data?: unknown, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
134
|
+
/**
|
|
135
|
+
* Internal method to perform the actual PUT request.
|
|
136
|
+
*/
|
|
137
|
+
private performPut;
|
|
138
|
+
/**
|
|
139
|
+
* Performs a PUT request and returns an Observable.
|
|
140
|
+
*/
|
|
141
|
+
put$<T>(url: string, data?: unknown, config?: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
142
|
+
/**
|
|
143
|
+
* Performs a PATCH request.
|
|
144
|
+
*/
|
|
145
|
+
patch<T>(url: string, data?: unknown, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
146
|
+
/**
|
|
147
|
+
* Internal method to perform the actual PATCH request.
|
|
148
|
+
*/
|
|
149
|
+
private performPatch;
|
|
150
|
+
/**
|
|
151
|
+
* Performs a PATCH request and returns an Observable.
|
|
152
|
+
*/
|
|
153
|
+
patch$<T>(url: string, data?: unknown, config?: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
154
|
+
/**
|
|
155
|
+
* Performs a DELETE request.
|
|
156
|
+
*/
|
|
157
|
+
delete<T>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
158
|
+
/**
|
|
159
|
+
* Internal method to perform the actual DELETE request.
|
|
160
|
+
*/
|
|
161
|
+
private performDelete;
|
|
162
|
+
/**
|
|
163
|
+
* Performs a DELETE request and returns an Observable.
|
|
164
|
+
*/
|
|
165
|
+
delete$<T>(url: string, config?: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
166
|
+
/**
|
|
167
|
+
* Performs a HEAD request.
|
|
168
|
+
*/
|
|
169
|
+
head<T>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
170
|
+
/**
|
|
171
|
+
* Internal method to perform the actual HEAD request.
|
|
172
|
+
*/
|
|
173
|
+
private performHead;
|
|
174
|
+
/**
|
|
175
|
+
* Performs a HEAD request and returns an Observable.
|
|
176
|
+
*/
|
|
177
|
+
head$<T>(url: string, config?: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
178
|
+
/**
|
|
179
|
+
* Performs an OPTIONS request.
|
|
180
|
+
*/
|
|
181
|
+
options<T>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
182
|
+
/**
|
|
183
|
+
* Internal method to perform the actual OPTIONS request.
|
|
184
|
+
*/
|
|
185
|
+
private performOptions;
|
|
186
|
+
/**
|
|
187
|
+
* Performs an OPTIONS request and returns an Observable.
|
|
188
|
+
*/
|
|
189
|
+
options$<T>(url: string, config?: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
190
|
+
/**
|
|
191
|
+
* Performs a custom HTTP request.
|
|
192
|
+
*/
|
|
193
|
+
request<T>(config: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
194
|
+
/**
|
|
195
|
+
* Internal method to perform the actual custom request.
|
|
196
|
+
*/
|
|
197
|
+
private performRequest;
|
|
198
|
+
/**
|
|
199
|
+
* Performs a custom HTTP request and returns an Observable.
|
|
200
|
+
*/
|
|
201
|
+
request$<T>(config: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
202
|
+
/**
|
|
203
|
+
* Sets the authorization token for requests.
|
|
204
|
+
*/
|
|
205
|
+
setAuthToken(token: string, type?: string): void;
|
|
206
|
+
/**
|
|
207
|
+
* Clears the authorization token.
|
|
208
|
+
*/
|
|
209
|
+
clearAuthToken(): void;
|
|
210
|
+
/**
|
|
211
|
+
* Processes an error through all registered error interceptors.
|
|
212
|
+
*/
|
|
213
|
+
private processErrorInterceptors;
|
|
214
|
+
/**
|
|
215
|
+
* Returns a masked version of the token showing only the initial characters.
|
|
216
|
+
*/
|
|
217
|
+
private static maskToken;
|
|
218
|
+
/**
|
|
219
|
+
* Wraps a promise-returning HTTP method with error interceptor processing.
|
|
220
|
+
*/
|
|
221
|
+
private wrapWithErrorInterceptors;
|
|
222
|
+
/**
|
|
223
|
+
* Transforms an Axios response to the standardized HTTP response format.
|
|
224
|
+
*/
|
|
225
|
+
private transformResponse;
|
|
226
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AXIOS_HTTP_PROVIDER = "AXIOS_HTTP_PROVIDER";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { HttpModule } from "./http.module";
|
|
2
|
+
export { HttpImplementationAxiosModule } from "./implementations/axios/axios.http.module";
|
|
3
|
+
export { HTTP_PROVIDER, HTTP_AXIOS_PROVIDER, HTTP_AXIOS_CONNECTION, } from "./http.token";
|
|
4
|
+
export type { HttpProviderInterface } from "./http.interface";
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adatechnology/http-client",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"@nestjs/common": "^11",
|
|
12
|
+
"@nestjs/core": "^11"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"prebuild": "rm -rf dist",
|
|
16
|
+
"build": "tsc -p tsconfig.json",
|
|
17
|
+
"check": "tsc -p tsconfig.json --noEmit"
|
|
18
|
+
}
|
|
19
|
+
}
|