hyperttp 0.2.5 → 0.3.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/Hyperttp/Client/HyperClient.d.ts +30 -0
- package/Hyperttp/Client/HyperClient.d.ts.map +1 -0
- package/Hyperttp/Client/HyperClient.js +215 -0
- package/Hyperttp/Client/HyperClient.js.map +1 -0
- package/{dist/Hyperttp → Hyperttp}/Request.d.ts +1 -1
- package/{dist/Hyperttp → Hyperttp}/Request.d.ts.map +1 -1
- package/{dist/Hyperttp → Hyperttp}/Request.js +2 -7
- package/Hyperttp/Request.js.map +1 -0
- package/{dist/Hyperttp → Hyperttp}/UrlExtractor.d.ts +1 -1
- package/{dist/Hyperttp → Hyperttp}/UrlExtractor.d.ts.map +1 -1
- package/{dist/Hyperttp → Hyperttp}/UrlExtractor.js +1 -4
- package/Hyperttp/UrlExtractor.js.map +1 -0
- package/Hyperttp/Utils/RequestBuilder.d.ts +32 -0
- package/Hyperttp/Utils/RequestBuilder.d.ts.map +1 -0
- package/Hyperttp/Utils/RequestBuilder.js +129 -0
- package/Hyperttp/Utils/RequestBuilder.js.map +1 -0
- package/Hyperttp/Utils/index.d.ts +2 -0
- package/Hyperttp/Utils/index.d.ts.map +1 -0
- package/Hyperttp/Utils/index.js +2 -0
- package/Hyperttp/Utils/index.js.map +1 -0
- package/Hyperttp/Utils/merge.d.ts +2 -0
- package/Hyperttp/Utils/merge.d.ts.map +1 -0
- package/Hyperttp/Utils/merge.js +25 -0
- package/Hyperttp/Utils/merge.js.map +1 -0
- package/Hyperttp/defaultConfig.d.ts +3 -0
- package/Hyperttp/defaultConfig.d.ts.map +1 -0
- package/Hyperttp/defaultConfig.js +39 -0
- package/Hyperttp/defaultConfig.js.map +1 -0
- package/Hyperttp/index.d.ts +6 -0
- package/Hyperttp/index.d.ts.map +1 -0
- package/Hyperttp/index.js +6 -0
- package/Hyperttp/index.js.map +1 -0
- package/{dist/Types → Types}/http-client.d.ts +3 -7
- package/Types/http-client.d.ts.map +1 -0
- package/Types/http-client.js +2 -0
- package/Types/index.d.ts +3 -0
- package/Types/index.d.ts.map +1 -0
- package/Types/index.js +3 -0
- package/Types/index.js.map +1 -0
- package/Types/url-extractor.js +2 -0
- package/index.d.ts +13 -0
- package/index.d.ts.map +1 -0
- package/index.js +12 -0
- package/index.js.map +1 -0
- package/package.json +22 -11
- package/LICENSE +0 -21
- package/README.md +0 -82
- package/dist/Hyperttp/Core/CacheManager.d.ts +0 -84
- package/dist/Hyperttp/Core/CacheManager.d.ts.map +0 -1
- package/dist/Hyperttp/Core/CacheManager.js +0 -109
- package/dist/Hyperttp/Core/CacheManager.js.map +0 -1
- package/dist/Hyperttp/Core/HttpClientImproved.d.ts +0 -149
- package/dist/Hyperttp/Core/HttpClientImproved.d.ts.map +0 -1
- package/dist/Hyperttp/Core/HttpClientImproved.js +0 -533
- package/dist/Hyperttp/Core/HttpClientImproved.js.map +0 -1
- package/dist/Hyperttp/Core/InterceptorManager.d.ts +0 -62
- package/dist/Hyperttp/Core/InterceptorManager.d.ts.map +0 -1
- package/dist/Hyperttp/Core/InterceptorManager.js +0 -64
- package/dist/Hyperttp/Core/InterceptorManager.js.map +0 -1
- package/dist/Hyperttp/Core/MetricsManager.d.ts +0 -71
- package/dist/Hyperttp/Core/MetricsManager.d.ts.map +0 -1
- package/dist/Hyperttp/Core/MetricsManager.js +0 -229
- package/dist/Hyperttp/Core/MetricsManager.js.map +0 -1
- package/dist/Hyperttp/Core/QueueManager.d.ts +0 -16
- package/dist/Hyperttp/Core/QueueManager.d.ts.map +0 -1
- package/dist/Hyperttp/Core/QueueManager.js +0 -69
- package/dist/Hyperttp/Core/QueueManager.js.map +0 -1
- package/dist/Hyperttp/Core/RateLimiter.d.ts +0 -63
- package/dist/Hyperttp/Core/RateLimiter.d.ts.map +0 -1
- package/dist/Hyperttp/Core/RateLimiter.js +0 -166
- package/dist/Hyperttp/Core/RateLimiter.js.map +0 -1
- package/dist/Hyperttp/Core/RequestBuilder.d.ts +0 -83
- package/dist/Hyperttp/Core/RequestBuilder.d.ts.map +0 -1
- package/dist/Hyperttp/Core/RequestBuilder.js +0 -169
- package/dist/Hyperttp/Core/RequestBuilder.js.map +0 -1
- package/dist/Hyperttp/Core/RequestExecutor.d.ts +0 -31
- package/dist/Hyperttp/Core/RequestExecutor.d.ts.map +0 -1
- package/dist/Hyperttp/Core/RequestExecutor.js +0 -166
- package/dist/Hyperttp/Core/RequestExecutor.js.map +0 -1
- package/dist/Hyperttp/Core/ResponseConverter.d.ts +0 -23
- package/dist/Hyperttp/Core/ResponseConverter.d.ts.map +0 -1
- package/dist/Hyperttp/Core/ResponseConverter.js +0 -368
- package/dist/Hyperttp/Core/ResponseConverter.js.map +0 -1
- package/dist/Hyperttp/Core/index.d.ts +0 -26
- package/dist/Hyperttp/Core/index.d.ts.map +0 -1
- package/dist/Hyperttp/Core/index.js +0 -54
- package/dist/Hyperttp/Core/index.js.map +0 -1
- package/dist/Hyperttp/Request.js.map +0 -1
- package/dist/Hyperttp/UrlExtractor.js.map +0 -1
- package/dist/Hyperttp/index.d.ts +0 -5
- package/dist/Hyperttp/index.d.ts.map +0 -1
- package/dist/Hyperttp/index.js +0 -23
- package/dist/Hyperttp/index.js.map +0 -1
- package/dist/Types/cache.d.ts +0 -10
- package/dist/Types/cache.d.ts.map +0 -1
- package/dist/Types/cache.js +0 -3
- package/dist/Types/cache.js.map +0 -1
- package/dist/Types/errors.d.ts +0 -15
- package/dist/Types/errors.d.ts.map +0 -1
- package/dist/Types/errors.js +0 -34
- package/dist/Types/errors.js.map +0 -1
- package/dist/Types/http-client.d.ts.map +0 -1
- package/dist/Types/http-client.js +0 -3
- package/dist/Types/http.d.ts +0 -5
- package/dist/Types/http.d.ts.map +0 -1
- package/dist/Types/http.js +0 -3
- package/dist/Types/http.js.map +0 -1
- package/dist/Types/index.d.ts +0 -13
- package/dist/Types/index.d.ts.map +0 -1
- package/dist/Types/index.js +0 -29
- package/dist/Types/index.js.map +0 -1
- package/dist/Types/interceptors.d.ts +0 -13
- package/dist/Types/interceptors.d.ts.map +0 -1
- package/dist/Types/interceptors.js +0 -3
- package/dist/Types/interceptors.js.map +0 -1
- package/dist/Types/metrics.d.ts +0 -67
- package/dist/Types/metrics.d.ts.map +0 -1
- package/dist/Types/metrics.js +0 -3
- package/dist/Types/metrics.js.map +0 -1
- package/dist/Types/options.d.ts +0 -233
- package/dist/Types/options.d.ts.map +0 -1
- package/dist/Types/options.js +0 -3
- package/dist/Types/options.js.map +0 -1
- package/dist/Types/queue.d.ts +0 -8
- package/dist/Types/queue.d.ts.map +0 -1
- package/dist/Types/queue.js +0 -3
- package/dist/Types/queue.js.map +0 -1
- package/dist/Types/request.d.ts +0 -189
- package/dist/Types/request.d.ts.map +0 -1
- package/dist/Types/request.js +0 -3
- package/dist/Types/request.js.map +0 -1
- package/dist/Types/response.d.ts +0 -28
- package/dist/Types/response.d.ts.map +0 -1
- package/dist/Types/response.js +0 -3
- package/dist/Types/response.js.map +0 -1
- package/dist/Types/stream.d.ts +0 -39
- package/dist/Types/stream.d.ts.map +0 -1
- package/dist/Types/stream.js +0 -3
- package/dist/Types/stream.js.map +0 -1
- package/dist/Types/url-extractor.js +0 -3
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -17
- package/dist/index.js.map +0 -1
- /package/{dist/Types → Types}/http-client.js.map +0 -0
- /package/{dist/Types → Types}/url-extractor.d.ts +0 -0
- /package/{dist/Types → Types}/url-extractor.d.ts.map +0 -0
- /package/{dist/Types → Types}/url-extractor.js.map +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const defaultConfig = {
|
|
2
|
+
network: {
|
|
3
|
+
timeout: 30000,
|
|
4
|
+
maxConcurrent: 500,
|
|
5
|
+
allowHttp2: true,
|
|
6
|
+
pipelining: 10,
|
|
7
|
+
keepAliveTimeout: 30000,
|
|
8
|
+
followRedirects: true,
|
|
9
|
+
maxRedirects: 5,
|
|
10
|
+
rejectUnauthorized: true,
|
|
11
|
+
userAgent: "Hyperttp/2.0",
|
|
12
|
+
},
|
|
13
|
+
retry: {
|
|
14
|
+
maxRetries: 3,
|
|
15
|
+
baseDelay: 100,
|
|
16
|
+
maxDelay: 5000,
|
|
17
|
+
jitter: true,
|
|
18
|
+
},
|
|
19
|
+
metrics: {
|
|
20
|
+
enabled: true,
|
|
21
|
+
},
|
|
22
|
+
cache: {
|
|
23
|
+
enabled: true,
|
|
24
|
+
ttl: 60000,
|
|
25
|
+
},
|
|
26
|
+
interceptors: {
|
|
27
|
+
enabled: true,
|
|
28
|
+
},
|
|
29
|
+
rateLimit: {
|
|
30
|
+
enabled: true,
|
|
31
|
+
maxRequests: 10000,
|
|
32
|
+
windowMs: 1000,
|
|
33
|
+
},
|
|
34
|
+
queue: {
|
|
35
|
+
enabled: true,
|
|
36
|
+
},
|
|
37
|
+
verbose: false,
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=defaultConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../../src/Hyperttp/defaultConfig.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAsB;IAC9C,OAAO,EAAE;QACP,OAAO,EAAE,KAAK;QACd,aAAa,EAAE,GAAG;QAClB,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,EAAE;QACd,gBAAgB,EAAE,KAAK;QACvB,eAAe,EAAE,IAAI;QACrB,YAAY,EAAE,CAAC;QACf,kBAAkB,EAAE,IAAI;QACxB,SAAS,EAAE,cAAc;KAC1B;IAED,KAAK,EAAE;QACL,UAAU,EAAE,CAAC;QACb,SAAS,EAAE,GAAG;QACd,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,IAAI;KACb;IAED,OAAO,EAAE;QACP,OAAO,EAAE,IAAI;KACd;IAED,KAAK,EAAE;QACL,OAAO,EAAE,IAAI;QACb,GAAG,EAAE,KAAK;KACX;IAED,YAAY,EAAE;QACZ,OAAO,EAAE,IAAI;KACd;IAED,SAAS,EAAE;QACT,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,KAAK;QAClB,QAAQ,EAAE,IAAI;KACf;IAED,KAAK,EAAE;QACL,OAAO,EAAE,IAAI;KACd;IAED,OAAO,EAAE,KAAK;CACf,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { HyperClient } from "./Client/HyperClient.js";
|
|
2
|
+
export { default as Request } from "./Request.js";
|
|
3
|
+
export { PreparedRequest } from "./Request.js";
|
|
4
|
+
export { default as UrlExtractor } from "./UrlExtractor.js";
|
|
5
|
+
export * from "./Utils/index.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Hyperttp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC5D,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { HyperClient } from "./Client/HyperClient.js";
|
|
2
|
+
export { default as Request } from "./Request.js";
|
|
3
|
+
export { PreparedRequest } from "./Request.js";
|
|
4
|
+
export { default as UrlExtractor } from "./UrlExtractor.js";
|
|
5
|
+
export * from "./Utils/index.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Hyperttp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC5D,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ResponseType } from "
|
|
3
|
-
import type { StreamResponse } from "./stream.js";
|
|
4
|
-
import type { RequestMetrics } from "./metrics.js";
|
|
5
|
-
import type { HttpClientOptions } from "./options.js";
|
|
6
|
-
import type { RequestBuilder } from "../Hyperttp/Core/RequestBuilder.js";
|
|
1
|
+
import { RequestBuilder } from "../Hyperttp/Utils/RequestBuilder.js";
|
|
2
|
+
import type { HttpClientOptions, RequestInterface, RequestMetrics, ResponseType, StreamResponse } from "@hyperttp/core";
|
|
7
3
|
export interface HttpClientStats {
|
|
8
4
|
cacheSize: number;
|
|
9
5
|
inflightRequests: number;
|
|
@@ -25,7 +21,7 @@ export interface HttpClientInterface {
|
|
|
25
21
|
options<T = unknown>(req: RequestInterface | string, body?: any, responseType?: ResponseType): Promise<T>;
|
|
26
22
|
head(req: RequestInterface | string): Promise<HeadResponse>;
|
|
27
23
|
stream(req: RequestInterface | string): Promise<StreamResponse>;
|
|
28
|
-
request
|
|
24
|
+
request(url: string): RequestBuilder;
|
|
29
25
|
create(options: Partial<HttpClientOptions>): HttpClientInterface;
|
|
30
26
|
extend(options: Partial<HttpClientOptions>): HttpClientInterface;
|
|
31
27
|
warmup(urls: string[], count?: number): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../src/Types/http-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,cAAc,EACf,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAEpC,GAAG,CAAC,CAAC,GAAG,OAAO,EACb,GAAG,EAAE,gBAAgB,GAAG,MAAM,EAC9B,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,CAAC,CAAC,CAAC;IAEd,IAAI,CAAC,CAAC,GAAG,OAAO,EACd,GAAG,EAAE,gBAAgB,GAAG,MAAM,EAC9B,IAAI,CAAC,EAAE,GAAG,EACV,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,CAAC,CAAC,CAAC;IAEd,GAAG,CAAC,CAAC,GAAG,OAAO,EACb,GAAG,EAAE,gBAAgB,GAAG,MAAM,EAC9B,IAAI,CAAC,EAAE,GAAG,EACV,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,CAAC,CAAC,CAAC;IAEd,KAAK,CAAC,CAAC,GAAG,OAAO,EACf,GAAG,EAAE,gBAAgB,GAAG,MAAM,EAC9B,IAAI,CAAC,EAAE,GAAG,EACV,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,CAAC,CAAC,CAAC;IAEd,MAAM,CAAC,CAAC,GAAG,OAAO,EAChB,GAAG,EAAE,gBAAgB,GAAG,MAAM,EAC9B,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,CAAC,CAAC,CAAC;IAEd,OAAO,CAAC,CAAC,GAAG,OAAO,EACjB,GAAG,EAAE,gBAAgB,GAAG,MAAM,EAC9B,IAAI,CAAC,EAAE,GAAG,EACV,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,CAAC,CAAC,CAAC;IAEd,IAAI,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAE5D,MAAM,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAEhE,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC;IAErC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,mBAAmB,CAAC;IACjE,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,mBAAmB,CAAC;IAEjE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtD,QAAQ,IAAI,eAAe,CAAC;IAC5B,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;IACpD,aAAa,IAAI,cAAc,EAAE,CAAC;IAClC,YAAY,IAAI,IAAI,CAAC;IACrB,UAAU,IAAI,IAAI,CAAC;IAEnB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B"}
|
package/Types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Types/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
|
package/Types/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Types/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { Request, PreparedRequest, UrlExtractor, HyperClient, } from "./Hyperttp/index.js";
|
|
2
|
+
export * from "./Types/index.js";
|
|
3
|
+
export type * from "./Types/index.js";
|
|
4
|
+
export * from "@hyperttp/cache";
|
|
5
|
+
export * from "@hyperttp/parser";
|
|
6
|
+
export * from "@hyperttp/inflight";
|
|
7
|
+
export * from "@hyperttp/interceptors";
|
|
8
|
+
export * from "@hyperttp/metrics";
|
|
9
|
+
export * from "@hyperttp/queue";
|
|
10
|
+
export * from "@hyperttp/serializer";
|
|
11
|
+
export * from "@hyperttp/ratelimit";
|
|
12
|
+
export * from "@hyperttp/retry";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,eAAe,EACf,YAAY,EACZ,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAE7B,cAAc,kBAAkB,CAAC;AAEjC,mBAAmB,kBAAkB,CAAC;AAEtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { Request, PreparedRequest, UrlExtractor, HyperClient, } from "./Hyperttp/index.js";
|
|
2
|
+
export * from "./Types/index.js";
|
|
3
|
+
export * from "@hyperttp/cache";
|
|
4
|
+
export * from "@hyperttp/parser";
|
|
5
|
+
export * from "@hyperttp/inflight";
|
|
6
|
+
export * from "@hyperttp/interceptors";
|
|
7
|
+
export * from "@hyperttp/metrics";
|
|
8
|
+
export * from "@hyperttp/queue";
|
|
9
|
+
export * from "@hyperttp/serializer";
|
|
10
|
+
export * from "@hyperttp/ratelimit";
|
|
11
|
+
export * from "@hyperttp/retry";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,eAAe,EACf,YAAY,EACZ,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAE7B,cAAc,kBAAkB,CAAC;AAIjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyperttp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "A high-performance, universal HTTP client for Node.js with caching, retries, queueing, rate limiting, cookies and logging.",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"types": "./index.d.ts",
|
|
7
8
|
"author": "dirold2",
|
|
8
9
|
"license": "MIT",
|
|
9
10
|
"repository": {
|
|
@@ -22,13 +23,23 @@
|
|
|
22
23
|
"cookies",
|
|
23
24
|
"logger"
|
|
24
25
|
],
|
|
26
|
+
"exports": {
|
|
27
|
+
"./*": {
|
|
28
|
+
"types": "./Types/*.d.ts",
|
|
29
|
+
"import": "./Types/*.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
25
32
|
"dependencies": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
+
"@hyperttp/core": "^1.1.7",
|
|
34
|
+
"@hyperttp/cache": "^1.0.13",
|
|
35
|
+
"@hyperttp/parser": "^1.0.18",
|
|
36
|
+
"@hyperttp/inflight": "^1.0.4",
|
|
37
|
+
"@hyperttp/interceptors": "^1.0.3",
|
|
38
|
+
"@hyperttp/metrics": "^1.0.3",
|
|
39
|
+
"@hyperttp/queue": "^1.0.3",
|
|
40
|
+
"@hyperttp/profiler": "^1.0.1",
|
|
41
|
+
"@hyperttp/serializer": "^1.0.4",
|
|
42
|
+
"@hyperttp/ratelimit": "^1.0.4",
|
|
43
|
+
"@hyperttp/retry": "^1.0.1"
|
|
33
44
|
}
|
|
34
|
-
}
|
|
45
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 [Your Name or Organization]
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# Hyperttp
|
|
2
|
-
|
|
3
|
-
Advanced HTTP client for Node.js with caching, rate limiting, request queuing, automatic retries, cookie management, and automatic JSON/XML parsing.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- Automatic request deduplication
|
|
8
|
-
- LRU caching with TTL
|
|
9
|
-
- Configurable rate limiting
|
|
10
|
-
- Concurrent request management
|
|
11
|
-
- Exponential backoff with jitter for retries
|
|
12
|
-
- Cookie jar support
|
|
13
|
-
- Automatic response parsing (JSON/XML/text/buffer)
|
|
14
|
-
- Automatic handling of redirects
|
|
15
|
-
- Fluent request builder API
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm install hyperttp
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Basic Usage
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
import HttpClientImproved from "hyperttp";
|
|
27
|
-
|
|
28
|
-
const client = new HttpClientImproved({
|
|
29
|
-
timeout: 10000,
|
|
30
|
-
maxConcurrent: 10,
|
|
31
|
-
logger: (level, msg) => console.log(`[${level}] ${msg}`),
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
// Simple GET request
|
|
35
|
-
const data = await client.get("https://api.example.com/data");
|
|
36
|
-
console.log(data);
|
|
37
|
-
|
|
38
|
-
// POST request with JSON body
|
|
39
|
-
const postData = await client.post("https://api.example.com/items", {
|
|
40
|
-
name: "Item 1",
|
|
41
|
-
});
|
|
42
|
-
console.log(postData);
|
|
43
|
-
|
|
44
|
-
// Using fluent RequestBuilder
|
|
45
|
-
const builderData = await client
|
|
46
|
-
.request("https://api.example.com/search")
|
|
47
|
-
.query({ q: "hyperttp", limit: 10 })
|
|
48
|
-
.headers({ Authorization: "Bearer TOKEN" })
|
|
49
|
-
.json()
|
|
50
|
-
.send();
|
|
51
|
-
|
|
52
|
-
console.log(builderData);
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Fluent Builder API
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
client
|
|
59
|
-
.request("https://api.example.com/data")
|
|
60
|
-
.get() // default
|
|
61
|
-
.headers({ "X-Test": "123" })
|
|
62
|
-
.query({ page: 1 })
|
|
63
|
-
.json() // or .text(), .xml()
|
|
64
|
-
.send()
|
|
65
|
-
.then(console.log);
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Advanced Features
|
|
69
|
-
|
|
70
|
-
- Caching: Automatically caches GET/HEAD responses, configurable TTL and max size
|
|
71
|
-
|
|
72
|
-
- Rate limiting: Prevents overwhelming servers
|
|
73
|
-
|
|
74
|
-
- Retries: Automatic retries for 408, 429, 500, 502, 503, 504 with exponential backoff
|
|
75
|
-
|
|
76
|
-
- Cookies: Persistent cookie jar per client
|
|
77
|
-
|
|
78
|
-
- Metrics: Track request timings, bytes sent/received, retries, and cache hits
|
|
79
|
-
|
|
80
|
-
## Documentation
|
|
81
|
-
|
|
82
|
-
- [Русский](https://github.com/Dirold2/hyperttp/blob/main/lang/ru/README.md)
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { CacheManagerOptions } from "../../Types/cache";
|
|
2
|
-
/**
|
|
3
|
-
* @class CacheManager
|
|
4
|
-
* @en High-performance in-memory cache based on LRU strategy.
|
|
5
|
-
* Provides TTL support, metadata storage (etag, lastModified) and fast key-value access.
|
|
6
|
-
*
|
|
7
|
-
* @ru Высокопроизводительный in-memory кэш на основе LRU стратегии.
|
|
8
|
-
* Поддерживает TTL, хранение метаданных (etag, lastModified) и быстрый доступ по ключу.
|
|
9
|
-
*/
|
|
10
|
-
export declare class CacheManager {
|
|
11
|
-
private readonly cache;
|
|
12
|
-
constructor(options?: CacheManagerOptions);
|
|
13
|
-
/**
|
|
14
|
-
* @en Retrieves cached value by key.
|
|
15
|
-
* @ru Получает значение из кэша по ключу.
|
|
16
|
-
*
|
|
17
|
-
* @template T
|
|
18
|
-
* @param key Cache key
|
|
19
|
-
* @returns Cached value or undefined if not found
|
|
20
|
-
*/
|
|
21
|
-
get<T>(key: string): T | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* @en Stores value in cache.
|
|
24
|
-
* @ru Сохраняет значение в кэш.
|
|
25
|
-
*
|
|
26
|
-
* @template T
|
|
27
|
-
* @param key Cache key
|
|
28
|
-
* @param value Value to store
|
|
29
|
-
*/
|
|
30
|
-
set<T>(key: string, value: T): void;
|
|
31
|
-
/**
|
|
32
|
-
* @en Retrieves cached entry with metadata (etag, lastModified).
|
|
33
|
-
* @ru Получает запись кэша вместе с метаданными (etag, lastModified).
|
|
34
|
-
*
|
|
35
|
-
* @template T
|
|
36
|
-
* @param key Cache key
|
|
37
|
-
* @returns Cached entry with metadata or undefined
|
|
38
|
-
*/
|
|
39
|
-
getWithMetadata<T>(key: string): {
|
|
40
|
-
data: T;
|
|
41
|
-
etag?: string;
|
|
42
|
-
lastModified?: string;
|
|
43
|
-
} | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* @en Stores value with optional HTTP metadata (etag, lastModified).
|
|
46
|
-
* @ru Сохраняет значение с дополнительными HTTP метаданными (etag, lastModified).
|
|
47
|
-
*
|
|
48
|
-
* @template T
|
|
49
|
-
* @param key Cache key
|
|
50
|
-
* @param data Value to store
|
|
51
|
-
* @param meta Optional HTTP metadata
|
|
52
|
-
*/
|
|
53
|
-
setWithMetadata<T>(key: string, data: T, meta?: {
|
|
54
|
-
etag?: string;
|
|
55
|
-
lastModified?: string;
|
|
56
|
-
}): void;
|
|
57
|
-
/**
|
|
58
|
-
* @en Checks if key exists in cache.
|
|
59
|
-
* @ru Проверяет наличие ключа в кэше.
|
|
60
|
-
*
|
|
61
|
-
* @param key Cache key
|
|
62
|
-
* @returns true if exists, otherwise false
|
|
63
|
-
*/
|
|
64
|
-
has(key: string): boolean;
|
|
65
|
-
/**
|
|
66
|
-
* @en Deletes value from cache by key.
|
|
67
|
-
* @ru Удаляет значение из кэша по ключу.
|
|
68
|
-
*
|
|
69
|
-
* @param key Cache key
|
|
70
|
-
* @returns true if value was removed
|
|
71
|
-
*/
|
|
72
|
-
delete(key: string): boolean;
|
|
73
|
-
/**
|
|
74
|
-
* @en Clears entire cache.
|
|
75
|
-
* @ru Очищает весь кэш.
|
|
76
|
-
*/
|
|
77
|
-
clear(): void;
|
|
78
|
-
/**
|
|
79
|
-
* @en Returns current cache size.
|
|
80
|
-
* @ru Возвращает текущий размер кэша.
|
|
81
|
-
*/
|
|
82
|
-
get size(): number;
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=CacheManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CacheManager.d.ts","sourceRoot":"","sources":["../../../src/Hyperttp/Core/CacheManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEpE;;;;;;;GAOG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoC;gBAE9C,OAAO,CAAC,EAAE,mBAAmB;IAQzC;;;;;;;OAOG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAIlC;;;;;;;OAOG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAMnC;;;;;;;OAOG;IACH,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAC1B;QACE,IAAI,EAAE,CAAC,CAAC;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GACD,SAAS;IAIb;;;;;;;;OAQG;IACH,eAAe,CAAC,CAAC,EACf,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,CAAC,EACP,IAAI,CAAC,EAAE;QACL,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GACA,IAAI;IAQP;;;;;;OAMG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B;;;OAGG;IACH,KAAK,IAAI,IAAI;IAIb;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CacheManager = void 0;
|
|
4
|
-
const lru_cache_1 = require("lru-cache");
|
|
5
|
-
/**
|
|
6
|
-
* @class CacheManager
|
|
7
|
-
* @en High-performance in-memory cache based on LRU strategy.
|
|
8
|
-
* Provides TTL support, metadata storage (etag, lastModified) and fast key-value access.
|
|
9
|
-
*
|
|
10
|
-
* @ru Высокопроизводительный in-memory кэш на основе LRU стратегии.
|
|
11
|
-
* Поддерживает TTL, хранение метаданных (etag, lastModified) и быстрый доступ по ключу.
|
|
12
|
-
*/
|
|
13
|
-
class CacheManager {
|
|
14
|
-
cache;
|
|
15
|
-
constructor(options) {
|
|
16
|
-
this.cache = new lru_cache_1.LRUCache({
|
|
17
|
-
max: options?.cacheMaxSize ?? 500,
|
|
18
|
-
ttl: options?.cacheTTL ?? 300_000,
|
|
19
|
-
updateAgeOnGet: true,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* @en Retrieves cached value by key.
|
|
24
|
-
* @ru Получает значение из кэша по ключу.
|
|
25
|
-
*
|
|
26
|
-
* @template T
|
|
27
|
-
* @param key Cache key
|
|
28
|
-
* @returns Cached value or undefined if not found
|
|
29
|
-
*/
|
|
30
|
-
get(key) {
|
|
31
|
-
return this.cache.get(key)?.data;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @en Stores value in cache.
|
|
35
|
-
* @ru Сохраняет значение в кэш.
|
|
36
|
-
*
|
|
37
|
-
* @template T
|
|
38
|
-
* @param key Cache key
|
|
39
|
-
* @param value Value to store
|
|
40
|
-
*/
|
|
41
|
-
set(key, value) {
|
|
42
|
-
this.cache.set(key, {
|
|
43
|
-
data: value,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* @en Retrieves cached entry with metadata (etag, lastModified).
|
|
48
|
-
* @ru Получает запись кэша вместе с метаданными (etag, lastModified).
|
|
49
|
-
*
|
|
50
|
-
* @template T
|
|
51
|
-
* @param key Cache key
|
|
52
|
-
* @returns Cached entry with metadata or undefined
|
|
53
|
-
*/
|
|
54
|
-
getWithMetadata(key) {
|
|
55
|
-
return this.cache.get(key);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* @en Stores value with optional HTTP metadata (etag, lastModified).
|
|
59
|
-
* @ru Сохраняет значение с дополнительными HTTP метаданными (etag, lastModified).
|
|
60
|
-
*
|
|
61
|
-
* @template T
|
|
62
|
-
* @param key Cache key
|
|
63
|
-
* @param data Value to store
|
|
64
|
-
* @param meta Optional HTTP metadata
|
|
65
|
-
*/
|
|
66
|
-
setWithMetadata(key, data, meta) {
|
|
67
|
-
this.cache.set(key, {
|
|
68
|
-
data,
|
|
69
|
-
etag: meta?.etag,
|
|
70
|
-
lastModified: meta?.lastModified,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* @en Checks if key exists in cache.
|
|
75
|
-
* @ru Проверяет наличие ключа в кэше.
|
|
76
|
-
*
|
|
77
|
-
* @param key Cache key
|
|
78
|
-
* @returns true if exists, otherwise false
|
|
79
|
-
*/
|
|
80
|
-
has(key) {
|
|
81
|
-
return this.cache.has(key);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* @en Deletes value from cache by key.
|
|
85
|
-
* @ru Удаляет значение из кэша по ключу.
|
|
86
|
-
*
|
|
87
|
-
* @param key Cache key
|
|
88
|
-
* @returns true if value was removed
|
|
89
|
-
*/
|
|
90
|
-
delete(key) {
|
|
91
|
-
return this.cache.delete(key);
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* @en Clears entire cache.
|
|
95
|
-
* @ru Очищает весь кэш.
|
|
96
|
-
*/
|
|
97
|
-
clear() {
|
|
98
|
-
this.cache.clear();
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* @en Returns current cache size.
|
|
102
|
-
* @ru Возвращает текущий размер кэша.
|
|
103
|
-
*/
|
|
104
|
-
get size() {
|
|
105
|
-
return this.cache.size;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
exports.CacheManager = CacheManager;
|
|
109
|
-
//# sourceMappingURL=CacheManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CacheManager.js","sourceRoot":"","sources":["../../../src/Hyperttp/Core/CacheManager.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AAGrC;;;;;;;GAOG;AACH,MAAa,YAAY;IACN,KAAK,CAAoC;IAE1D,YAAY,OAA6B;QACvC,IAAI,CAAC,KAAK,GAAG,IAAI,oBAAQ,CAAC;YACxB,GAAG,EAAE,OAAO,EAAE,YAAY,IAAI,GAAG;YACjC,GAAG,EAAE,OAAO,EAAE,QAAQ,IAAI,OAAO;YACjC,cAAc,EAAE,IAAI;SACrB,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,GAAG,CAAI,GAAW;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IACnC,CAAC;IAED;;;;;;;OAOG;IACH,GAAG,CAAI,GAAW,EAAE,KAAQ;QAC1B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;YAClB,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,eAAe,CAAI,GAAW;QAO5B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;;;;OAQG;IACH,eAAe,CACb,GAAW,EACX,IAAO,EACP,IAGC;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;YAClB,IAAI;YACJ,IAAI,EAAE,IAAI,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI,EAAE,YAAY;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,GAAW;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED;;;OAGG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;CACF;AApHD,oCAoHC"}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { RequestBuilder } from "./RequestBuilder.js";
|
|
2
|
-
import { HttpClientInterface } from "../../Types/http-client.js";
|
|
3
|
-
import { HttpClientOptions } from "../../Types/options.js";
|
|
4
|
-
import { ResponseType } from "../../Types/http.js";
|
|
5
|
-
import { RequestInterface } from "../../Types/request.js";
|
|
6
|
-
import { RequestMetrics } from "../../Types/metrics.js";
|
|
7
|
-
import { StreamResponse } from "../../Types/stream.js";
|
|
8
|
-
import { Readable } from "node:stream";
|
|
9
|
-
/**
|
|
10
|
-
* @class HttpClientImproved
|
|
11
|
-
* @en High-performance HTTP client with built-in caching, queuing, rate limiting, and metrics.
|
|
12
|
-
* @ru Высокопроизводительный HTTP-клиент со встроенным кэшированием, очередями, лимитами и метриками.
|
|
13
|
-
*/
|
|
14
|
-
export default class HttpClientImproved implements HttpClientInterface {
|
|
15
|
-
private agent;
|
|
16
|
-
readonly config: HttpClientOptions;
|
|
17
|
-
private cache?;
|
|
18
|
-
private queue?;
|
|
19
|
-
private limiter?;
|
|
20
|
-
private metricsManager;
|
|
21
|
-
private interceptors;
|
|
22
|
-
private executor;
|
|
23
|
-
private converter;
|
|
24
|
-
private inflight;
|
|
25
|
-
private defaultHeaders;
|
|
26
|
-
private readonly cacheEnabled;
|
|
27
|
-
private readonly queueEnabled;
|
|
28
|
-
private readonly limiterEnabled;
|
|
29
|
-
private readonly metricsEnabled;
|
|
30
|
-
private readonly verboseEnabled;
|
|
31
|
-
constructor(config?: HttpClientOptions);
|
|
32
|
-
/**
|
|
33
|
-
* @en Performs an HTTP GET request.
|
|
34
|
-
* @ru Выполняет HTTP GET запрос.
|
|
35
|
-
* @param req Request URL or Request object
|
|
36
|
-
* @param responseType Expected response format
|
|
37
|
-
*/
|
|
38
|
-
get<T = any>(req: RequestInterface | string, responseType?: ResponseType): Promise<T>;
|
|
39
|
-
/**
|
|
40
|
-
* @en Performs an HTTP POST request.
|
|
41
|
-
* @ru Выполняет HTTP POST запрос.
|
|
42
|
-
* @param req Request URL or Request object
|
|
43
|
-
* @param body Request body data
|
|
44
|
-
* @param responseType Expected response format
|
|
45
|
-
*/
|
|
46
|
-
post<T = any>(req: RequestInterface | string, body?: any, responseType?: ResponseType): Promise<T>;
|
|
47
|
-
/**
|
|
48
|
-
* @en Performs an HTTP PUT request.
|
|
49
|
-
* @ru Выполняет HTTP PUT запрос.
|
|
50
|
-
*/
|
|
51
|
-
put<T = any>(req: RequestInterface | string, body?: any, responseType?: ResponseType): Promise<T>;
|
|
52
|
-
/**
|
|
53
|
-
* @en Performs an HTTP DELETE request.
|
|
54
|
-
* @ru Выполняет HTTP DELETE запрос.
|
|
55
|
-
*/
|
|
56
|
-
delete<T = any>(req: RequestInterface | string, responseType?: ResponseType): Promise<T>;
|
|
57
|
-
/**
|
|
58
|
-
* @en Performs an HTTP PATCH request.
|
|
59
|
-
* @ru Выполняет HTTP PATCH запрос.
|
|
60
|
-
*/
|
|
61
|
-
patch<T = any>(req: RequestInterface | string, body?: any, responseType?: ResponseType): Promise<T>;
|
|
62
|
-
/**
|
|
63
|
-
* @en Performs an HTTP OPTIONS request.
|
|
64
|
-
* @ru Выполняет HTTP OPTIONS запрос.
|
|
65
|
-
*/
|
|
66
|
-
options<T = any>(req: RequestInterface | string, body?: any, responseType?: ResponseType): Promise<T>;
|
|
67
|
-
/**
|
|
68
|
-
* @en Performs an HTTP HEAD request.
|
|
69
|
-
* @ru Выполняет HTTP HEAD запрос.
|
|
70
|
-
*/
|
|
71
|
-
head(req: RequestInterface | string): Promise<{
|
|
72
|
-
status: number;
|
|
73
|
-
headers: Record<string, any>;
|
|
74
|
-
}>;
|
|
75
|
-
/**
|
|
76
|
-
* @en Creates a new HttpClient instance with merged configuration.
|
|
77
|
-
* @ru Создаёт новый экземпляр HttpClient с объединённой конфигурацией.
|
|
78
|
-
*
|
|
79
|
-
* @param options Partial configuration to override current settings
|
|
80
|
-
* @returns New HttpClientImproved instance
|
|
81
|
-
*/
|
|
82
|
-
extend(options: Partial<HttpClientOptions>): HttpClientImproved;
|
|
83
|
-
/**
|
|
84
|
-
* @en Alias for extend(). Creates a new configured client instance.
|
|
85
|
-
* @ru Алиас для extend(). Создаёт новый настроенный экземпляр клиента.
|
|
86
|
-
*
|
|
87
|
-
* @param options Partial configuration overrides
|
|
88
|
-
* @returns New HttpClientImproved instance
|
|
89
|
-
*/
|
|
90
|
-
create(options: Partial<HttpClientOptions>): HttpClientImproved;
|
|
91
|
-
/**
|
|
92
|
-
* @en Executes a request and returns an AsyncIterable stream.
|
|
93
|
-
* @ru Выполняет запрос и возвращает итерируемый поток данных.
|
|
94
|
-
*/
|
|
95
|
-
stream(req: RequestInterface | string): Promise<StreamResponse<Readable>>;
|
|
96
|
-
/**
|
|
97
|
-
* @en Creates a RequestBuilder for a fluent API approach.
|
|
98
|
-
* @ru Создает RequestBuilder для использования Fluent API.
|
|
99
|
-
* @example client.request('url').get().send();
|
|
100
|
-
*/
|
|
101
|
-
request<T = any>(url: string): RequestBuilder<T>;
|
|
102
|
-
destroy(): Promise<void>;
|
|
103
|
-
clearCache(): void;
|
|
104
|
-
/**
|
|
105
|
-
* @en Clears all collected performance metrics.
|
|
106
|
-
* @ru Очищает все собранные метрики производительности.
|
|
107
|
-
*/
|
|
108
|
-
clearMetrics(): void;
|
|
109
|
-
/**
|
|
110
|
-
* @en Retrieves metrics for a specific URL.
|
|
111
|
-
* @ru Получает метрики для конкретного URL.
|
|
112
|
-
*/
|
|
113
|
-
getMetrics(key: string): RequestMetrics | undefined;
|
|
114
|
-
/**
|
|
115
|
-
* @en Retrieves all stored request metrics.
|
|
116
|
-
* @ru Получает список всех сохраненных метрик.
|
|
117
|
-
*/
|
|
118
|
-
getAllMetrics(): RequestMetrics[];
|
|
119
|
-
/**
|
|
120
|
-
* @en Returns real-time statistics about the client's internal state.
|
|
121
|
-
* @ru Возвращает статистику состояния клиента в реальном времени.
|
|
122
|
-
* @returns Cache size, active requests, queue state, etc.
|
|
123
|
-
*/
|
|
124
|
-
getStats(): {
|
|
125
|
-
cacheSize: number;
|
|
126
|
-
inflightRequests: number;
|
|
127
|
-
queuedRequests: any;
|
|
128
|
-
activeRequests: any;
|
|
129
|
-
currentRateLimit: any;
|
|
130
|
-
};
|
|
131
|
-
warmup(urls: string[], count?: number): Promise<void>;
|
|
132
|
-
private mergeOptions;
|
|
133
|
-
private normalizeRequest;
|
|
134
|
-
private applyDefaulthcoptions;
|
|
135
|
-
/**
|
|
136
|
-
* @en Core internal method for handling all HTTP requests.
|
|
137
|
-
* @ru Основной внутренний метод для обработки всех HTTP-запросов.
|
|
138
|
-
* @param method HTTP method (GET, POST, etc.)
|
|
139
|
-
* @param req Request object
|
|
140
|
-
* @param useCache Whether to use caching for this request
|
|
141
|
-
* @param responseType Expected response format
|
|
142
|
-
*/
|
|
143
|
-
private requestInternal;
|
|
144
|
-
private prepareRequestData;
|
|
145
|
-
private createInitialMetrics;
|
|
146
|
-
private recordSuccess;
|
|
147
|
-
private recordError;
|
|
148
|
-
}
|
|
149
|
-
//# sourceMappingURL=HttpClientImproved.d.ts.map
|