@adatechnology/http-client 0.0.1 → 0.0.2
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 +6 -0
- package/dist/{types/http.interface.d.ts → index.d.ts} +28 -18
- package/dist/index.js +787 -11
- package/package.json +7 -3
- package/src/errors/base-app-error.ts +25 -0
- package/src/errors/error-mapper.service.ts +60 -0
- package/src/errors/http-client-error.ts +7 -0
- package/src/implementations/axios/axios.http.provider.ts +19 -1
- package/tsconfig.json +4 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/tsconfig.tsup.json +6 -0
- package/tsup.config.ts +14 -0
- package/dist/http.interface.js +0 -27
- package/dist/http.module.js +0 -37
- package/dist/http.provider.js +0 -137
- package/dist/http.token.js +0 -6
- package/dist/implementations/axios/axios.http.module.js +0 -41
- package/dist/implementations/axios/axios.http.provider.js +0 -424
- package/dist/implementations/axios/axios.http.token.js +0 -4
- package/dist/implementations/http.implementation.module.js +0 -20
- package/dist/types/http.module.d.ts +0 -9
- package/dist/types/http.provider.d.ts +0 -43
- package/dist/types/http.token.d.ts +0 -3
- package/dist/types/implementations/axios/axios.http.module.d.ts +0 -5
- package/dist/types/implementations/axios/axios.http.provider.d.ts +0 -226
- package/dist/types/implementations/axios/axios.http.token.d.ts +0 -1
- package/dist/types/implementations/http.implementation.module.d.ts +0 -2
- package/dist/types/index.d.ts +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { AxiosRequestConfig, AxiosInstance } from 'axios';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
declare class HttpModule {
|
|
6
|
+
/**
|
|
7
|
+
* Configure HttpModule with an Axios instance or AxiosRequestConfig.
|
|
8
|
+
* This will import the implementation-specific module (currently Axios).
|
|
9
|
+
*/
|
|
10
|
+
static forRoot(config?: AxiosRequestConfig | AxiosInstance): DynamicModule;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare class HttpImplementationAxiosModule {
|
|
14
|
+
static forRoot(config?: AxiosRequestConfig | AxiosInstance): DynamicModule;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare const HTTP_AXIOS_CONNECTION = "HTTP_AXIOS_CONNECTION";
|
|
18
|
+
declare const HTTP_AXIOS_PROVIDER = "HTTP_AXIOS_PROVIDER";
|
|
19
|
+
declare const HTTP_PROVIDER = "HTTP_PROVIDER";
|
|
20
|
+
|
|
2
21
|
/**
|
|
3
22
|
* HTTP methods supported
|
|
4
23
|
*/
|
|
5
|
-
|
|
24
|
+
declare enum HttpMethod {
|
|
6
25
|
GET = "GET",
|
|
7
26
|
POST = "POST",
|
|
8
27
|
PUT = "PUT",
|
|
@@ -14,7 +33,7 @@ export declare enum HttpMethod {
|
|
|
14
33
|
/**
|
|
15
34
|
* Content types for HTTP requests
|
|
16
35
|
*/
|
|
17
|
-
|
|
36
|
+
declare enum ContentType {
|
|
18
37
|
JSON = "application/json",
|
|
19
38
|
FORM_URLENCODED = "application/x-www-form-urlencoded",
|
|
20
39
|
FORM_DATA = "multipart/form-data",
|
|
@@ -24,7 +43,7 @@ export declare enum ContentType {
|
|
|
24
43
|
/**
|
|
25
44
|
* HTTP request configuration
|
|
26
45
|
*/
|
|
27
|
-
|
|
46
|
+
interface HttpRequestConfig {
|
|
28
47
|
url: string;
|
|
29
48
|
method?: HttpMethod;
|
|
30
49
|
headers?: Record<string, string>;
|
|
@@ -42,7 +61,7 @@ export interface HttpRequestConfig {
|
|
|
42
61
|
/**
|
|
43
62
|
* HTTP response structure
|
|
44
63
|
*/
|
|
45
|
-
|
|
64
|
+
interface HttpResponse<T = any> {
|
|
46
65
|
data: T;
|
|
47
66
|
status: number;
|
|
48
67
|
statusText: string;
|
|
@@ -50,25 +69,14 @@ export interface HttpResponse<T = any> {
|
|
|
50
69
|
config: HttpRequestConfig;
|
|
51
70
|
request?: any;
|
|
52
71
|
}
|
|
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
72
|
/**
|
|
65
73
|
* Error interceptor function
|
|
66
74
|
*/
|
|
67
|
-
|
|
75
|
+
type ErrorInterceptor = (error: any) => any;
|
|
68
76
|
/**
|
|
69
77
|
* HTTP provider interface
|
|
70
78
|
*/
|
|
71
|
-
|
|
79
|
+
interface HttpProviderInterface {
|
|
72
80
|
/**
|
|
73
81
|
* Make a GET request
|
|
74
82
|
*/
|
|
@@ -173,3 +181,5 @@ export interface HttpProviderInterface {
|
|
|
173
181
|
options$<T = any>(url: string, config?: Omit<HttpRequestConfig, "url" | "method">): Observable<HttpResponse<T>>;
|
|
174
182
|
request$<T = any>(config: HttpRequestConfig): Observable<HttpResponse<T>>;
|
|
175
183
|
}
|
|
184
|
+
|
|
185
|
+
export { HTTP_AXIOS_CONNECTION, HTTP_AXIOS_PROVIDER, HTTP_PROVIDER, HttpImplementationAxiosModule, HttpModule, type HttpProviderInterface };
|