hyperttp 0.2.0 → 0.2.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/README.md +55 -65
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,48 +1,29 @@
|
|
|
1
1
|
# Hyperttp
|
|
2
2
|
|
|
3
|
-
Advanced HTTP client for Node.js with caching, rate limiting, request queuing, automatic retries, cookie management, and
|
|
3
|
+
Advanced HTTP client for Node.js with caching, rate limiting, request queuing, automatic retries, cookie management, and automatic JSON/XML parsing.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
## Installation
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## Russian Version
|
|
25
|
-
|
|
26
|
-
### Описание
|
|
27
|
-
|
|
28
|
-
Расширенный HTTP клиент для Node.js с кэшированием, ограничением запросов, очередями запросов, автоматическими повторными попытками, управлением cookie и декомпрессией ответов.
|
|
29
|
-
|
|
30
|
-
### Возможности
|
|
31
|
-
|
|
32
|
-
* Автоматическое предотвращение дублирования запросов
|
|
33
|
-
* LRU кэширование с TTL
|
|
34
|
-
* Настраиваемое ограничение запросов
|
|
35
|
-
* Управление конкурентными запросами
|
|
36
|
-
* Экспоненциальная задержка с джиттером
|
|
37
|
-
* Поддержка cookie jar
|
|
38
|
-
* Автопарсинг JSON/XML
|
|
39
|
-
* Поддержка сжатия (gzip, deflate, brotli)
|
|
19
|
+
```bash
|
|
20
|
+
npm install hyperttp
|
|
21
|
+
```
|
|
40
22
|
|
|
41
|
-
|
|
23
|
+
## Basic Usage
|
|
42
24
|
|
|
43
|
-
```
|
|
44
|
-
import HttpClientImproved from
|
|
45
|
-
import Request from './src/Hyperttp/Request';
|
|
25
|
+
```typescript
|
|
26
|
+
import HttpClientImproved from "hyperttp";
|
|
46
27
|
|
|
47
28
|
const client = new HttpClientImproved({
|
|
48
29
|
timeout: 10000,
|
|
@@ -50,43 +31,52 @@ const client = new HttpClientImproved({
|
|
|
50
31
|
logger: (level, msg) => console.log(`[${level}] ${msg}`),
|
|
51
32
|
});
|
|
52
33
|
|
|
53
|
-
|
|
54
|
-
const data = await client.get(
|
|
34
|
+
// Simple GET request
|
|
35
|
+
const data = await client.get("https://api.example.com/data");
|
|
55
36
|
console.log(data);
|
|
56
|
-
```
|
|
57
37
|
|
|
58
|
-
|
|
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);
|
|
59
43
|
|
|
60
|
-
|
|
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();
|
|
61
51
|
|
|
62
|
-
|
|
52
|
+
console.log(builderData);
|
|
53
|
+
```
|
|
63
54
|
|
|
64
|
-
|
|
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
|
+
```
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
## Advanced Features
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
* LRU caching with TTL
|
|
70
|
-
* Configurable rate limiting
|
|
71
|
-
* Concurrent request management
|
|
72
|
-
* Exponential backoff with jitter
|
|
73
|
-
* Cookie jar support
|
|
74
|
-
* Automatic response parsing (JSON/XML)
|
|
75
|
-
* Compression support (gzip, deflate, brotli)
|
|
70
|
+
- Caching: Automatically caches GET/HEAD responses, configurable TTL and max size
|
|
76
71
|
|
|
77
|
-
|
|
72
|
+
- Rate limiting: Prevents overwhelming servers
|
|
78
73
|
|
|
79
|
-
|
|
80
|
-
import HttpClientImproved from './src/Hyperttp/Core/HttpClientImproved';
|
|
81
|
-
import Request from './src/Hyperttp/Request';
|
|
74
|
+
- Retries: Automatic retries for 408, 429, 500, 502, 503, 504 with exponential backoff
|
|
82
75
|
|
|
83
|
-
|
|
84
|
-
timeout: 10000,
|
|
85
|
-
maxConcurrent: 10,
|
|
86
|
-
logger: (level, msg) => console.log(`[${level}] ${msg}`),
|
|
87
|
-
});
|
|
76
|
+
- Cookies: Persistent cookie jar per client
|
|
88
77
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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)
|
package/package.json
CHANGED