create-request 0.0.1-beta.17 → 0.0.1-beta.19
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 +36 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
- [CSRF Protection](#csrf-protection)
|
|
19
19
|
- [Performance Considerations](#performance-considerations)
|
|
20
20
|
- [Browser Support](#browser-support)
|
|
21
|
+
- [Comparison of JavaScript HTTP Client Libraries](#comparison-of-javascript-http-client-libraries)
|
|
21
22
|
- [License](#license)
|
|
22
23
|
|
|
23
24
|
## Core Features
|
|
@@ -142,6 +143,17 @@ const request = create
|
|
|
142
143
|
// Authentication methods
|
|
143
144
|
.withBearerToken("your-token") // Adds Authorization: Bearer your-token
|
|
144
145
|
.withBasicAuth("username", "password") // HTTP Basic Authentication
|
|
146
|
+
.withAuthorization("auth-scheme value") // Custom authorization header
|
|
147
|
+
|
|
148
|
+
// Add a single cookie
|
|
149
|
+
.withCookie("language", "en-US")
|
|
150
|
+
|
|
151
|
+
// Add multiple cookies
|
|
152
|
+
.withCookies({
|
|
153
|
+
sessionId: "abc123",
|
|
154
|
+
preferences: { value: "dark-mode", secure: true },
|
|
155
|
+
tracking: { value: "enabled", sameSite: SameSitePolicy.STRICT },
|
|
156
|
+
})
|
|
145
157
|
|
|
146
158
|
// URL parameters
|
|
147
159
|
.withQueryParams({ search: "term", page: 1, limit: 20 })
|
|
@@ -156,7 +168,8 @@ const request = create
|
|
|
156
168
|
.withRedirect(RedirectMode.FOLLOW) // Controls redirect behavior (follow, error, manual)
|
|
157
169
|
.withReferrer("https://example.com") // Sets request referrer
|
|
158
170
|
.withReferrerPolicy(ReferrerPolicy.NO_REFERRER_WHEN_DOWNGRADE) // Controls referrer policy
|
|
159
|
-
.withPriority(RequestPriority.HIGH)
|
|
171
|
+
.withPriority(RequestPriority.HIGH) // Sets request priority
|
|
172
|
+
.withKeepAlive(true); // Keeps connection alive after the page is unloaded
|
|
160
173
|
```
|
|
161
174
|
|
|
162
175
|
Each configuration method returns the request object, allowing for a fluent interface where methods can be chained together. You can configure only what you need for a specific request:
|
|
@@ -554,34 +567,31 @@ This library works with all browsers that support the Fetch API:
|
|
|
554
567
|
|
|
555
568
|
## Comparison of JavaScript HTTP Client Libraries
|
|
556
569
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
|
560
|
-
|
|
|
561
|
-
| **
|
|
562
|
-
| **
|
|
563
|
-
| **
|
|
564
|
-
| **
|
|
565
|
-
| **
|
|
566
|
-
| **
|
|
567
|
-
| **
|
|
568
|
-
| **
|
|
569
|
-
| **
|
|
570
|
-
| **
|
|
571
|
-
| **
|
|
572
|
-
| **
|
|
573
|
-
| **
|
|
574
|
-
| **
|
|
575
|
-
| **
|
|
576
|
-
| **
|
|
577
|
-
| **Fluent/Chainable API** | ✅ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |
|
|
578
|
-
| **CSRF Protection** | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
570
|
+
| Feature | create-request | Fetch | Axios | SuperAgent | Got | Ky | node-fetch | Redaxios |
|
|
571
|
+
| ------------------- | -------------- | ------ | ------- | ---------- | ------- | ------ | ---------- | -------- |
|
|
572
|
+
| **Size (min+gzip)** | ~5.1KB | Native | ~13.6KB | ~17.8KB | ~17.8KB | ~3.4KB | ~7.7KB | ~1KB |
|
|
573
|
+
| **Browser** | Modern | Modern | IE11+ | IE9+ | ❌ No | Modern | ❌ No | Modern |
|
|
574
|
+
| **Node.js** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
575
|
+
| **HTTP/2** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
|
|
576
|
+
| **Auto Retries** | ✅ | ❌ | 🛠️ | ✅ | ✅ | ✅ | ❌ | ❌ |
|
|
577
|
+
| **Cancellation** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
578
|
+
| **Caching** | ✅ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |
|
|
579
|
+
| **Auto JSON** | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ |
|
|
580
|
+
| **Timeout** | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
581
|
+
| **TypeScript** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
582
|
+
| **Streaming** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
583
|
+
| **Progress** | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
|
|
584
|
+
| **Middleware** | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
|
|
585
|
+
| **Cookies** | ✅ | ✅ | 🛠️ | ✅ | ✅ | ❌ | ❌ | ❌ |
|
|
586
|
+
| **Pagination API** | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
|
|
587
|
+
| **Zero Deps** | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
588
|
+
| **Chainable API** | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ | ❌ |
|
|
589
|
+
| **CSRF Protection** | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
579
590
|
|
|
580
591
|
**Notes:**
|
|
581
592
|
|
|
582
|
-
-
|
|
583
|
-
-
|
|
584
|
-
- "CSRF Protection" refers to built-in mechanisms for CSRF defense.
|
|
593
|
+
- "Modern" browser support: Chrome 42+, Firefox 39+, Safari 10.1+, Edge 14+, Opera 29+
|
|
594
|
+
- 🛠️ Feature requires additional plugins or adapters (not available out-of-the-box)
|
|
585
595
|
|
|
586
596
|
## License
|
|
587
597
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-request",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.19",
|
|
4
4
|
"description": "A modern, chainable wrapper for fetch with automatic retries, timeouts, comprehensive error handling, and first-class TypeScript support",
|
|
5
5
|
"main": "dist/library/index.js",
|
|
6
6
|
"module": "dist/library/index.esm.js",
|