@npora/request 1.21.1 → 1.21.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/README.md +63 -12
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
[](package.json)
|
|
7
7
|
[](LICENSE)
|
|
8
8
|
|
|
9
|
+
[Website & live playground](https://npora.pages.dev) ·
|
|
10
|
+
[API reference](https://github.com/npora/request/blob/main/docs/api.md) ·
|
|
11
|
+
[Changelog](https://github.com/npora/request/blob/main/CHANGELOG.md)
|
|
12
|
+
|
|
9
13
|
A production-focused, TypeScript-first HTTP client built on the standard Fetch
|
|
10
14
|
API. It adds typed responses, runtime validation, streaming, stable errors, and
|
|
11
15
|
composable resilience while keeping native platform values visible. The package
|
|
@@ -16,16 +20,49 @@ has zero runtime dependencies.
|
|
|
16
20
|
| Goal | Documentation |
|
|
17
21
|
| --- | --- |
|
|
18
22
|
| Send the first request | [Quick start](#quick-start) |
|
|
19
|
-
|
|
|
23
|
+
| Try real requests in the browser | [Live playground](https://npora.pages.dev/#playground) |
|
|
24
|
+
| Develop or deploy the website | [Cloudflare Pages guide](https://github.com/npora/request/blob/main/docs/cloudflare-website.md) |
|
|
25
|
+
| Move an existing Axios client | [Axios migration guide](https://github.com/npora/request/blob/main/docs/axios-migration.md) |
|
|
20
26
|
| Consume SSE or NDJSON | [Streaming responses](#streaming-responses) |
|
|
21
|
-
| Run a complete session workflow | [Session example](docs/workflows.md#build-a-session-client) |
|
|
22
|
-
| Refresh authentication tokens | [Authentication workflow](docs/workflows.md#refresh-authentication-tokens) |
|
|
23
|
-
| Find a client or response API | [API reference](docs/api.md) |
|
|
24
|
-
| Configure URLs, bodies, timeouts, or parsing | [Configuration reference](docs/configuration.md) |
|
|
27
|
+
| Run a complete session workflow | [Session example](https://github.com/npora/request/blob/main/docs/workflows.md#build-a-session-client) |
|
|
28
|
+
| Refresh authentication tokens | [Authentication workflow](https://github.com/npora/request/blob/main/docs/workflows.md#refresh-authentication-tokens) |
|
|
29
|
+
| Find a client or response API | [API reference](https://github.com/npora/request/blob/main/docs/api.md) |
|
|
30
|
+
| Configure URLs, bodies, timeouts, or parsing | [Configuration reference](https://github.com/npora/request/blob/main/docs/configuration.md) |
|
|
25
31
|
| Add retry, cache, authentication, or observability | [Plugins](#plugins) |
|
|
26
32
|
| Handle stable error codes | [Errors](#errors) |
|
|
27
|
-
| Configure Node.js proxying, pooling, mTLS, or DNS | [Undici integration](docs/undici.md) |
|
|
28
|
-
| Review runtime boundaries and release checks | [Runtime support](docs/runtimes.md), [testing](docs/testing.md), and [security](docs/security.md) |
|
|
33
|
+
| Configure Node.js proxying, pooling, mTLS, or DNS | [Undici integration](https://github.com/npora/request/blob/main/docs/undici.md) |
|
|
34
|
+
| Review runtime boundaries and release checks | [Runtime support](https://github.com/npora/request/blob/main/docs/runtimes.md), [testing](https://github.com/npora/request/blob/main/docs/testing.md), and [security](https://github.com/npora/request/blob/main/docs/security.md) |
|
|
35
|
+
|
|
36
|
+
## Live playground
|
|
37
|
+
|
|
38
|
+
Try the library at **[npora.pages.dev](https://npora.pages.dev/#playground)**.
|
|
39
|
+
The console uses the request client built from this repository and makes real
|
|
40
|
+
same-origin requests to Cloudflare Pages Functions. Its displayed version comes
|
|
41
|
+
from the package manifest.
|
|
42
|
+
|
|
43
|
+
| Scenario | What to observe |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| JSON requests | A complete user object returned by `GET`. |
|
|
46
|
+
| Runtime validation | Invalid fields rejected with `SCHEMA_ERROR` and field-level issues. |
|
|
47
|
+
| Content-bearing queries | An actual HTTP `QUERY` request carrying nested JSON filters. |
|
|
48
|
+
| SSE | Three events consumed incrementally, with connection state and cancellation. |
|
|
49
|
+
| NDJSON | Records parsed and validated one at a time. |
|
|
50
|
+
| Retry | Two `503` responses followed by a successful third attempt. |
|
|
51
|
+
| Timeout and circuit breaking | `TIMEOUT_ERROR`, then `CIRCUIT_OPEN` without another network request. |
|
|
52
|
+
| Transfer progress | A one-MiB upload in acknowledged 64-KiB parts and a paced one-MiB download. |
|
|
53
|
+
| Authentication | Two expired-token requests sharing one refresh before replay. |
|
|
54
|
+
| Traffic control | Actual IP-limit observations, a labelled `429` recovery probe, queueing and local `RATE_LIMIT`. |
|
|
55
|
+
|
|
56
|
+
Failures are deliberately generated for these demonstrations. The upload
|
|
57
|
+
splitting is application code composed with the upload plugin. Real IP limits
|
|
58
|
+
use server arrival times; a separate, clearly labelled probe makes
|
|
59
|
+
`Retry-After` recovery observable even when a slow connection never exceeds
|
|
60
|
+
the real limit. Mock users and tokens are demonstration data.
|
|
61
|
+
|
|
62
|
+
The website and its build tools are separate from the npm package. Installing
|
|
63
|
+
`@npora/request` adds no runtime dependencies or website server code. See the
|
|
64
|
+
[Cloudflare deployment guide](https://github.com/npora/request/blob/main/docs/cloudflare-website.md)
|
|
65
|
+
for local setup, API routes and bindings.
|
|
29
66
|
|
|
30
67
|
## Install
|
|
31
68
|
|
|
@@ -241,11 +278,11 @@ iterator; each connection uses its own request timeout.
|
|
|
241
278
|
|
|
242
279
|
`onStateChange` observes `connecting`, `open`, `reconnecting`, `closed`, and
|
|
243
280
|
`errored`. It is available before the initial promise resolves; callback
|
|
244
|
-
failures are isolated. See the [streaming workflow](docs/workflows.md#consume-streaming-responses)
|
|
281
|
+
failures are isolated. See the [streaming workflow](https://github.com/npora/request/blob/main/docs/workflows.md#consume-streaming-responses)
|
|
245
282
|
for terminal-state and cancellation details.
|
|
246
283
|
|
|
247
284
|
Run `pnpm example:streaming` for a local demonstration. See
|
|
248
|
-
[streaming workflows](docs/workflows.md#consume-streaming-responses) for
|
|
285
|
+
[streaming workflows](https://github.com/npora/request/blob/main/docs/workflows.md#consume-streaming-responses) for
|
|
249
286
|
consumption and error-handling contracts.
|
|
250
287
|
|
|
251
288
|
Native `FormData`, `Blob`, `ArrayBuffer`, and `ReadableStream` request bodies
|
|
@@ -358,7 +395,7 @@ const request = createClient().use(retryPlugin({ retries: 2 }))
|
|
|
358
395
|
Retry is opt-in: installing `retryPlugin()` without a `retries` value leaves
|
|
359
396
|
the default at zero. Cache is also opt-in per request, or through a client
|
|
360
397
|
default under `extensions.cache`. See the
|
|
361
|
-
[configuration reference](docs/configuration.md#extension-options) for the
|
|
398
|
+
[configuration reference](https://github.com/npora/request/blob/main/docs/configuration.md#extension-options) for the
|
|
362
399
|
precise defaults and method rules.
|
|
363
400
|
|
|
364
401
|
For a smaller memory-only cache, import `memoryCachePlugin` from
|
|
@@ -412,7 +449,7 @@ const user = await request.get<User>('/users/1', {
|
|
|
412
449
|
cache.clear()
|
|
413
450
|
```
|
|
414
451
|
|
|
415
|
-
See [cache workflows](docs/cache.md) for request sharing, cache updates, tag
|
|
452
|
+
See [cache workflows](https://github.com/npora/request/blob/main/docs/cache.md) for request sharing, cache updates, tag
|
|
416
453
|
invalidation, HTTP revalidation, stale recovery, persistent stores, and
|
|
417
454
|
coordination across browser tabs.
|
|
418
455
|
|
|
@@ -615,7 +652,7 @@ request failures through the unified base class while still inspecting schema
|
|
|
615
652
|
issues when `error.code === 'SCHEMA_ERROR'`.
|
|
616
653
|
|
|
617
654
|
Use `isRequestError()` and `isSchemaValidationError()` to narrow unknown errors
|
|
618
|
-
across realms and package copies. See [error handling](docs/errors.md) for
|
|
655
|
+
across realms and package copies. See [error handling](https://github.com/npora/request/blob/main/docs/errors.md) for
|
|
619
656
|
recovery, cancellation, and retry decisions.
|
|
620
657
|
|
|
621
658
|
## Supply-chain verification
|
|
@@ -628,6 +665,8 @@ allowlist, and size budgets.
|
|
|
628
665
|
|
|
629
666
|
## Documentation
|
|
630
667
|
|
|
668
|
+
- [Live playground](https://npora.pages.dev/#playground)
|
|
669
|
+
- [Website development and Cloudflare deployment](https://github.com/npora/request/blob/main/docs/cloudflare-website.md)
|
|
631
670
|
- [Configuration reference](https://github.com/npora/request/blob/main/docs/configuration.md)
|
|
632
671
|
- [API reference](https://github.com/npora/request/blob/main/docs/api.md)
|
|
633
672
|
- [Architecture](https://github.com/npora/request/blob/main/docs/architecture.md)
|
|
@@ -659,6 +698,18 @@ See the
|
|
|
659
698
|
[testing and release gates](https://github.com/npora/request/blob/main/docs/testing.md)
|
|
660
699
|
for the complete matrix.
|
|
661
700
|
|
|
701
|
+
To run the website locally, install its isolated tools and build its public assets:
|
|
702
|
+
|
|
703
|
+
```sh
|
|
704
|
+
npm ci --prefix website --ignore-scripts
|
|
705
|
+
pnpm website:build
|
|
706
|
+
pnpm website:dev
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
Open `http://127.0.0.1:8787`. The development command starts Pages and its local
|
|
710
|
+
state Worker. Website checks are `pnpm test:website` and
|
|
711
|
+
`pnpm test:website:browser`; they do not deploy or publish anything.
|
|
712
|
+
|
|
662
713
|
## Versioning
|
|
663
714
|
|
|
664
715
|
`@npora/request` follows Semantic Versioning. Exports from every public
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npora/request",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.2",
|
|
4
4
|
"description": "A modern, TypeScript-first HTTP client powered by the Fetch API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"npora",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"circuit-breaker",
|
|
21
21
|
"web-worker"
|
|
22
22
|
],
|
|
23
|
-
"homepage": "https://
|
|
23
|
+
"homepage": "https://npora.pages.dev",
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|
|
26
26
|
"url": "git+https://github.com/npora/request.git"
|
|
@@ -153,6 +153,10 @@
|
|
|
153
153
|
"vitest": "^4.1.12"
|
|
154
154
|
},
|
|
155
155
|
"scripts": {
|
|
156
|
+
"website:build": "npm --prefix website run build",
|
|
157
|
+
"website:dev": "npm --prefix website run dev",
|
|
158
|
+
"test:website": "npm --prefix website test",
|
|
159
|
+
"test:website:browser": "playwright test --config=website/playwright.config.ts",
|
|
156
160
|
"clean": "node scripts/clean.mjs",
|
|
157
161
|
"clean:dry-run": "node scripts/clean.mjs --dry-run",
|
|
158
162
|
"dev": "tsdown --watch",
|