@whatwg-node/fetch 0.6.3-alpha-20230130162825-1e02017 → 0.6.3
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 +105 -43
- package/README.md +130 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,90 +1,133 @@
|
|
|
1
1
|
# @whatwg-node/fetch
|
|
2
2
|
|
|
3
|
-
## 0.6.3
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- [#154](https://github.com/ardatan/whatwg-node/pull/154)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
-
|
|
3
|
+
## 0.6.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#154](https://github.com/ardatan/whatwg-node/pull/154)
|
|
8
|
+
[`9f4fe48`](https://github.com/ardatan/whatwg-node/commit/9f4fe489ff1d08d873a2dd26c02abc54da08dc48)
|
|
9
|
+
Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
|
|
10
|
+
|
|
11
|
+
- Updated dependency
|
|
12
|
+
[`web-streams-polyfill@^3.2.1` ↗︎](https://www.npmjs.com/package/web-streams-polyfill/v/3.2.1)
|
|
13
|
+
(from `^3.2.0`, in `dependencies`)
|
|
14
|
+
- Added dependency
|
|
15
|
+
[`@whatwg-node/node-fetch@0.0.0` ↗︎](https://www.npmjs.com/package/@whatwg-node/node-fetch/v/0.0.0)
|
|
16
|
+
(to `dependencies`)
|
|
17
|
+
- Removed dependency
|
|
18
|
+
[`abort-controller@^3.0.0` ↗︎](https://www.npmjs.com/package/abort-controller/v/3.0.0) (from
|
|
19
|
+
`dependencies`)
|
|
20
|
+
- Removed dependency
|
|
21
|
+
[`form-data-encoder@^1.7.1` ↗︎](https://www.npmjs.com/package/form-data-encoder/v/1.7.1) (from
|
|
22
|
+
`dependencies`)
|
|
23
|
+
- Removed dependency
|
|
24
|
+
[`formdata-node@^4.3.1` ↗︎](https://www.npmjs.com/package/formdata-node/v/4.3.1) (from
|
|
25
|
+
`dependencies`)
|
|
26
|
+
- Removed dependency [`node-fetch@^2.6.7` ↗︎](https://www.npmjs.com/package/node-fetch/v/2.6.7)
|
|
27
|
+
(from `dependencies`)
|
|
28
|
+
- Removed dependency [`undici@^5.12.0` ↗︎](https://www.npmjs.com/package/undici/v/5.12.0) (from
|
|
29
|
+
`dependencies`)
|
|
30
|
+
|
|
31
|
+
- [#154](https://github.com/ardatan/whatwg-node/pull/154)
|
|
32
|
+
[`9f4fe48`](https://github.com/ardatan/whatwg-node/commit/9f4fe489ff1d08d873a2dd26c02abc54da08dc48)
|
|
33
|
+
Thanks [@ardatan](https://github.com/ardatan)! - New Fetch API implementation for Node
|
|
34
|
+
|
|
35
|
+
- Updated dependencies
|
|
36
|
+
[[`9f4fe48`](https://github.com/ardatan/whatwg-node/commit/9f4fe489ff1d08d873a2dd26c02abc54da08dc48)]:
|
|
37
|
+
- @whatwg-node/node-fetch@0.0.1
|
|
21
38
|
|
|
22
39
|
## 0.6.2
|
|
23
40
|
|
|
24
41
|
### Patch Changes
|
|
25
42
|
|
|
26
|
-
- [#258](https://github.com/ardatan/whatwg-node/pull/258)
|
|
43
|
+
- [#258](https://github.com/ardatan/whatwg-node/pull/258)
|
|
44
|
+
[`802cb96`](https://github.com/ardatan/whatwg-node/commit/802cb9636eddd8e819b80604fc26d40aac92c828)
|
|
45
|
+
Thanks [@enisdenjo](https://github.com/enisdenjo)! - Node ponyfill requests must have an abort
|
|
46
|
+
signal
|
|
27
47
|
|
|
28
48
|
## 0.6.1
|
|
29
49
|
|
|
30
50
|
### Patch Changes
|
|
31
51
|
|
|
32
|
-
- [`9752cca`](https://github.com/ardatan/whatwg-node/commit/9752cca54e7636114d87849ca9c7eb9be3d9dba8)
|
|
52
|
+
- [`9752cca`](https://github.com/ardatan/whatwg-node/commit/9752cca54e7636114d87849ca9c7eb9be3d9dba8)
|
|
53
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Remove unnecessary ponyfill for the envs
|
|
54
|
+
supporting Fetch by default
|
|
33
55
|
|
|
34
56
|
## 0.6.0
|
|
35
57
|
|
|
36
58
|
### Minor Changes
|
|
37
59
|
|
|
38
|
-
- [#241](https://github.com/ardatan/whatwg-node/pull/241)
|
|
60
|
+
- [#241](https://github.com/ardatan/whatwg-node/pull/241)
|
|
61
|
+
[`563cfaa`](https://github.com/ardatan/whatwg-node/commit/563cfaaacf8bb0b08371b7f44887321d7e7c472d)
|
|
62
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Drop itty-router in favor of new URLPattern in
|
|
63
|
+
the fetch ponyfill
|
|
39
64
|
|
|
40
65
|
### Patch Changes
|
|
41
66
|
|
|
42
|
-
- [#241](https://github.com/ardatan/whatwg-node/pull/241)
|
|
43
|
-
|
|
67
|
+
- [#241](https://github.com/ardatan/whatwg-node/pull/241)
|
|
68
|
+
[`563cfaa`](https://github.com/ardatan/whatwg-node/commit/563cfaaacf8bb0b08371b7f44887321d7e7c472d)
|
|
69
|
+
Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
|
|
70
|
+
- Added dependency
|
|
71
|
+
[`urlpattern-polyfill@^6.0.2` ↗︎](https://www.npmjs.com/package/urlpattern-polyfill/v/6.0.2) (to
|
|
72
|
+
`dependencies`)
|
|
44
73
|
|
|
45
74
|
## 0.5.4
|
|
46
75
|
|
|
47
76
|
### Patch Changes
|
|
48
77
|
|
|
49
|
-
- [#237](https://github.com/ardatan/whatwg-node/pull/237)
|
|
78
|
+
- [#237](https://github.com/ardatan/whatwg-node/pull/237)
|
|
79
|
+
[`166102f`](https://github.com/ardatan/whatwg-node/commit/166102f6ff52d2197ab7f78c63392b95ebca259c)
|
|
80
|
+
Thanks [@enisdenjo](https://github.com/enisdenjo)! - http2 support when using Node ponyfill
|
|
50
81
|
|
|
51
82
|
## 0.5.3
|
|
52
83
|
|
|
53
84
|
### Patch Changes
|
|
54
85
|
|
|
55
|
-
- [`188ac01`](https://github.com/ardatan/whatwg-node/commit/188ac01dab264ed483dbc3b897e6958b49085922)
|
|
86
|
+
- [`188ac01`](https://github.com/ardatan/whatwg-node/commit/188ac01dab264ed483dbc3b897e6958b49085922)
|
|
87
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Fix destroy for Node 18
|
|
56
88
|
|
|
57
89
|
## 0.5.2
|
|
58
90
|
|
|
59
91
|
### Patch Changes
|
|
60
92
|
|
|
61
|
-
- [#179](https://github.com/ardatan/whatwg-node/pull/179)
|
|
93
|
+
- [#179](https://github.com/ardatan/whatwg-node/pull/179)
|
|
94
|
+
[`3297c87`](https://github.com/ardatan/whatwg-node/commit/3297c87409c3bcf8700dd447d603da657acbd821)
|
|
95
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Fix destroy method for ReadableStream to Readable
|
|
96
|
+
conversion
|
|
62
97
|
|
|
63
98
|
## 0.5.1
|
|
64
99
|
|
|
65
100
|
### Patch Changes
|
|
66
101
|
|
|
67
|
-
- [`a8a7cfc`](https://github.com/ardatan/whatwg-node/commit/a8a7cfcbb98c5ca8fff3b4a6d8638e9208690b61)
|
|
102
|
+
- [`a8a7cfc`](https://github.com/ardatan/whatwg-node/commit/a8a7cfcbb98c5ca8fff3b4a6d8638e9208690b61)
|
|
103
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Fix for new undici
|
|
68
104
|
|
|
69
105
|
## 0.5.0
|
|
70
106
|
|
|
71
107
|
### Minor Changes
|
|
72
108
|
|
|
73
|
-
- [`ab5fb52`](https://github.com/ardatan/whatwg-node/commit/ab5fb524753bc7a210b1aaf2e1580566907d4713)
|
|
109
|
+
- [`ab5fb52`](https://github.com/ardatan/whatwg-node/commit/ab5fb524753bc7a210b1aaf2e1580566907d4713)
|
|
110
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Drop broken `fieldsFirst` flag
|
|
74
111
|
|
|
75
112
|
## 0.4.7
|
|
76
113
|
|
|
77
114
|
### Patch Changes
|
|
78
115
|
|
|
79
|
-
- [`e59cbb6`](https://github.com/ardatan/whatwg-node/commit/e59cbb667dfcbdd9c0cf609fd56dbd904ac85cbd)
|
|
116
|
+
- [`e59cbb6`](https://github.com/ardatan/whatwg-node/commit/e59cbb667dfcbdd9c0cf609fd56dbd904ac85cbd)
|
|
117
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Do not patch global Headers if it is native, and
|
|
118
|
+
support URL as a first parameter of `fetch`
|
|
80
119
|
|
|
81
120
|
## 0.4.6
|
|
82
121
|
|
|
83
122
|
### Patch Changes
|
|
84
123
|
|
|
85
|
-
- [`c918527`](https://github.com/ardatan/whatwg-node/commit/c918527f15eb6096656376648dccdbc8d6898395)
|
|
124
|
+
- [`c918527`](https://github.com/ardatan/whatwg-node/commit/c918527f15eb6096656376648dccdbc8d6898395)
|
|
125
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Bump Undici
|
|
86
126
|
|
|
87
|
-
- [#148](https://github.com/ardatan/whatwg-node/pull/148)
|
|
127
|
+
- [#148](https://github.com/ardatan/whatwg-node/pull/148)
|
|
128
|
+
[`eb10500`](https://github.com/ardatan/whatwg-node/commit/eb105005fd01bd227eff8d52c22b39ea1a8c6700)
|
|
129
|
+
Thanks [@ardatan](https://github.com/ardatan)! - - On Node 14, fix the return method of
|
|
130
|
+
Response.body's AsyncIterator to close HTTP connection correctly
|
|
88
131
|
- On Node 14, handle ReadableStream's cancel correctly if Response.body is a ReadableStream
|
|
89
132
|
- Do not modify ReadableStream.cancel's behavior but handle it internally
|
|
90
133
|
- On Node 18, do not combine Response.body's return and AbortController which causes a memory leak
|
|
@@ -93,65 +136,84 @@
|
|
|
93
136
|
|
|
94
137
|
### Patch Changes
|
|
95
138
|
|
|
96
|
-
- [#140](https://github.com/ardatan/whatwg-node/pull/140)
|
|
139
|
+
- [#140](https://github.com/ardatan/whatwg-node/pull/140)
|
|
140
|
+
[`5d151df`](https://github.com/ardatan/whatwg-node/commit/5d151df8c59329a470b8ffa6e3547aae72a7e55b)
|
|
141
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Fix Request.formData method
|
|
97
142
|
|
|
98
143
|
## 0.4.4
|
|
99
144
|
|
|
100
145
|
### Patch Changes
|
|
101
146
|
|
|
102
|
-
- [`9502102`](https://github.com/ardatan/whatwg-node/commit/9502102b265945b37ee38b276ec1533fae0f308f)
|
|
147
|
+
- [`9502102`](https://github.com/ardatan/whatwg-node/commit/9502102b265945b37ee38b276ec1533fae0f308f)
|
|
148
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Breaking Change: Event API is no longer available
|
|
149
|
+
in this ponyfill; use @whatwg-node/events instead.
|
|
103
150
|
|
|
104
151
|
## 0.4.3
|
|
105
152
|
|
|
106
153
|
### Patch Changes
|
|
107
154
|
|
|
108
|
-
- [`c9f05f2`](https://github.com/ardatan/whatwg-node/commit/c9f05f21fb96f63bc22359e3b7981cb9b3b727b5)
|
|
155
|
+
- [`c9f05f2`](https://github.com/ardatan/whatwg-node/commit/c9f05f21fb96f63bc22359e3b7981cb9b3b727b5)
|
|
156
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Add ponyfills for Response.redirect,
|
|
157
|
+
Response.json and Response.error
|
|
109
158
|
|
|
110
159
|
## 0.4.2
|
|
111
160
|
|
|
112
161
|
### Patch Changes
|
|
113
162
|
|
|
114
|
-
- [`7f37b6d`](https://github.com/ardatan/whatwg-node/commit/7f37b6dbeb76cfa54e0ed8672812bf016c1df4fa)
|
|
163
|
+
- [`7f37b6d`](https://github.com/ardatan/whatwg-node/commit/7f37b6dbeb76cfa54e0ed8672812bf016c1df4fa)
|
|
164
|
+
Thanks [@ardatan](https://github.com/ardatan)! - fix(fetch): respect filesLimit even with
|
|
165
|
+
fieldsFirst
|
|
115
166
|
|
|
116
167
|
## 0.4.1
|
|
117
168
|
|
|
118
169
|
### Patch Changes
|
|
119
170
|
|
|
120
|
-
- [`53753bb`](https://github.com/ardatan/whatwg-node/commit/53753bb5dd83fbc1e7253784b02f2b1f2e02fdb9)
|
|
171
|
+
- [`53753bb`](https://github.com/ardatan/whatwg-node/commit/53753bb5dd83fbc1e7253784b02f2b1f2e02fdb9)
|
|
172
|
+
Thanks [@ardatan](https://github.com/ardatan)! - fix(fetch): fix formData function
|
|
121
173
|
|
|
122
174
|
## 0.4.0
|
|
123
175
|
|
|
124
176
|
### Minor Changes
|
|
125
177
|
|
|
126
|
-
- [`005937c`](https://github.com/ardatan/whatwg-node/commit/005937c72749dfa3914c8b6193a88c772a522275)
|
|
178
|
+
- [`005937c`](https://github.com/ardatan/whatwg-node/commit/005937c72749dfa3914c8b6193a88c772a522275)
|
|
179
|
+
Thanks [@ardatan](https://github.com/ardatan)! - feat(fetch): new `fieldsFirst` option to allow
|
|
180
|
+
async stream consumption for multipart forms
|
|
127
181
|
|
|
128
|
-
- [`effc03d`](https://github.com/ardatan/whatwg-node/commit/effc03d58793328595183ac7cd5c9abab95dec17)
|
|
182
|
+
- [`effc03d`](https://github.com/ardatan/whatwg-node/commit/effc03d58793328595183ac7cd5c9abab95dec17)
|
|
183
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Bun Support
|
|
129
184
|
|
|
130
185
|
## 0.3.2
|
|
131
186
|
|
|
132
187
|
### Patch Changes
|
|
133
188
|
|
|
134
|
-
- [`982fa96`](https://github.com/ardatan/whatwg-node/commit/982fa96b09af404a21154098499202bfd29c2054)
|
|
189
|
+
- [`982fa96`](https://github.com/ardatan/whatwg-node/commit/982fa96b09af404a21154098499202bfd29c2054)
|
|
190
|
+
Thanks [@ardatan](https://github.com/ardatan)! - fix(ponyfill/btoa): handle incoming value as
|
|
191
|
+
binary encoding
|
|
135
192
|
|
|
136
193
|
## 0.3.1
|
|
137
194
|
|
|
138
195
|
### Patch Changes
|
|
139
196
|
|
|
140
|
-
- [`a3bc171`](https://github.com/ardatan/whatwg-node/commit/a3bc17120fbdf641e4363d08ba79955005f5b3d6)
|
|
197
|
+
- [`a3bc171`](https://github.com/ardatan/whatwg-node/commit/a3bc17120fbdf641e4363d08ba79955005f5b3d6)
|
|
198
|
+
Thanks [@ardatan](https://github.com/ardatan)! - fix btoa ponyfill
|
|
141
199
|
|
|
142
200
|
## 0.3.0
|
|
143
201
|
|
|
144
202
|
### Minor Changes
|
|
145
203
|
|
|
146
|
-
- [`8a431d3`](https://github.com/ardatan/whatwg-node/commit/8a431d309271c0d1ff7248ec26afe293ccc01bf6)
|
|
204
|
+
- [`8a431d3`](https://github.com/ardatan/whatwg-node/commit/8a431d309271c0d1ff7248ec26afe293ccc01bf6)
|
|
205
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Add "btoa" ponyfill for Node 14
|
|
147
206
|
|
|
148
|
-
* [`8a431d3`](https://github.com/ardatan/whatwg-node/commit/8a431d309271c0d1ff7248ec26afe293ccc01bf6)
|
|
207
|
+
* [`8a431d3`](https://github.com/ardatan/whatwg-node/commit/8a431d309271c0d1ff7248ec26afe293ccc01bf6)
|
|
208
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Support different encodings in TextEncoder and
|
|
209
|
+
TextDecoder
|
|
149
210
|
|
|
150
211
|
## 0.2.9
|
|
151
212
|
|
|
152
213
|
### Patch Changes
|
|
153
214
|
|
|
154
|
-
- [`9a8d873`](https://github.com/ardatan/whatwg-node/commit/9a8d8731ff07ea585b1e561718584fbe5edeb963)
|
|
215
|
+
- [`9a8d873`](https://github.com/ardatan/whatwg-node/commit/9a8d8731ff07ea585b1e561718584fbe5edeb963)
|
|
216
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Workaround for a potential leak on Node 18
|
|
155
217
|
|
|
156
218
|
## 0.2.3
|
|
157
219
|
|
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# `@whatwg-node/fetch`
|
|
2
|
+
|
|
3
|
+
A ponyfill package for the [Fetch Standard](https://fetch.spec.whatwg.org/). If your JavaScript
|
|
4
|
+
environment doesn't implement this standard natively, this package automatically ponyfills the
|
|
5
|
+
missing parts, and export them as a module; otherwise it exports the native ones without touching
|
|
6
|
+
the environment's internals. It also exports some additional standard APIs that are required by the
|
|
7
|
+
Fetch Standard.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
yarn add @whatwg-node/fetch
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Why Fetch API and why this ponyfill in general?
|
|
16
|
+
|
|
17
|
+
If you are building a JavaScript library, and you want it to support all JavaScript environments not
|
|
18
|
+
only Node.js. Fetch API is the best choice for you. Because it's a standard, and it's implemented by
|
|
19
|
+
the most environments out there expect Node.js :). So you can use Fetch API in your library, and
|
|
20
|
+
your users can use it in their browsers, Deno, Bun, Cloudflare Works, and in Node.js.
|
|
21
|
+
|
|
22
|
+
> This is how we support all JavaScript environments in
|
|
23
|
+
> [GraphQL Yoga](https://the-guild.dev/graphql/yoga-server/docs/integrations/z-other-environments).
|
|
24
|
+
> In GraphQL Yoga, we don't care which JavaScript environment you prefer, we support all of them.
|
|
25
|
+
|
|
26
|
+
## Why we should still use these for Node.js even if it already implements them natively
|
|
27
|
+
|
|
28
|
+
Even if newer Node.js already implements Fetch API and Data Text Encoding API natively, we still
|
|
29
|
+
recommend to use this package, because this package implements them for Node.js in more efficient
|
|
30
|
+
way.
|
|
31
|
+
|
|
32
|
+
- [See problems with the global fetch/undici in Node.js](https://github.com/nodejs/undici/issues/1203)
|
|
33
|
+
- - We offer a patched version of `node-fetch` that doesn't use `undici` and Node.js streams
|
|
34
|
+
internally, so it's more efficient than the native one.
|
|
35
|
+
- [See problems with text encoding API in Node.js](https://github.com/nodejs/node/issues/39879)
|
|
36
|
+
- - We use [`Buffer`](https://nodejs.org/api/buffer.html) instead of the native one, because
|
|
37
|
+
`Buffer` is faster than the native one unfortunately.
|
|
38
|
+
- `Body.formData()` is not implemented by Node.js, so we implement it with `busboy` internally. So
|
|
39
|
+
you can consume incoming multipart(file uploads) requests with `.formData` in Node.js.
|
|
40
|
+
|
|
41
|
+
### Handling file uploads with Fetch API
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { Request } from '@whatwg-node/fetch'
|
|
45
|
+
|
|
46
|
+
// See how you can handle file uploads with Fetch API
|
|
47
|
+
http.createServer(async (req, res) => {
|
|
48
|
+
const request = new Request(req)
|
|
49
|
+
const formData = await request.formData()
|
|
50
|
+
const file = formData.get('file')
|
|
51
|
+
// ...
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
> If you want to limit the size of the multipart form data, you can use `createFetch`. See the
|
|
56
|
+
> [API](#api) section for more details.
|
|
57
|
+
|
|
58
|
+
## API
|
|
59
|
+
|
|
60
|
+
The following are exported by this package:
|
|
61
|
+
|
|
62
|
+
### WHATWG Fetch Standard
|
|
63
|
+
|
|
64
|
+
- [fetch](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch)
|
|
65
|
+
- [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
66
|
+
- [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
67
|
+
- [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers)
|
|
68
|
+
- [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
|
|
69
|
+
- [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)
|
|
70
|
+
|
|
71
|
+
### Web Streams API
|
|
72
|
+
|
|
73
|
+
- [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)
|
|
74
|
+
- [WritableStream](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream)
|
|
75
|
+
- [TransformStream](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream)
|
|
76
|
+
|
|
77
|
+
### URL Standard
|
|
78
|
+
|
|
79
|
+
- [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern)
|
|
80
|
+
|
|
81
|
+
### Data Types
|
|
82
|
+
|
|
83
|
+
- [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
|
|
84
|
+
- [File](https://developer.mozilla.org/en-US/docs/Web/API/File)
|
|
85
|
+
|
|
86
|
+
### Data Encoding/Decoding API
|
|
87
|
+
|
|
88
|
+
- [TextEncoder](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder)
|
|
89
|
+
- [TextDecoder](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder)
|
|
90
|
+
- [btoa](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/btoa)
|
|
91
|
+
|
|
92
|
+
### Web Crypto API
|
|
93
|
+
|
|
94
|
+
- [crypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)
|
|
95
|
+
|
|
96
|
+
### Create variations of the implementation
|
|
97
|
+
|
|
98
|
+
- `createFetch`
|
|
99
|
+
|
|
100
|
+
`createFetch` allows you to create an API with some specific flags that are not available in the
|
|
101
|
+
actual API.
|
|
102
|
+
|
|
103
|
+
#### Limit the multipart form data size
|
|
104
|
+
|
|
105
|
+
This is useful if you parse the multipart request bodies with `.formData()`.
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
import { createFetch } from '@whatwg-node/fetch'
|
|
109
|
+
|
|
110
|
+
const fetchAPI = createFetch({
|
|
111
|
+
formDataLimits: {
|
|
112
|
+
// Maximum allowed file size (in bytes)
|
|
113
|
+
fileSize: 1000000,
|
|
114
|
+
// Maximum allowed number of files
|
|
115
|
+
files: 10,
|
|
116
|
+
// Maximum allowed size of content (operations, variables etc...)
|
|
117
|
+
fieldSize: 1000000,
|
|
118
|
+
// Maximum allowed header size for form data
|
|
119
|
+
headerSize: 1000000
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
// See how you can handle file uploads with Fetch API
|
|
124
|
+
http.createServer(async (req, res) => {
|
|
125
|
+
const request = new Request(req)
|
|
126
|
+
const formData = await request.formData()
|
|
127
|
+
const file = formData.get('file')
|
|
128
|
+
// ...
|
|
129
|
+
})
|
|
130
|
+
```
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whatwg-node/fetch",
|
|
3
|
-
"version": "0.6.3
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Cross Platform Smart Fetch Ponyfill",
|
|
5
|
-
"author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",
|
|
6
5
|
"repository": {
|
|
7
6
|
"type": "git",
|
|
8
7
|
"url": "ardatan/whatwg-node",
|
|
9
8
|
"directory": "packages/fetch"
|
|
10
9
|
},
|
|
10
|
+
"author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"sideEffects": false,
|
|
13
12
|
"main": "dist/node-ponyfill.js",
|
|
14
13
|
"browser": "dist/global-ponyfill.js",
|
|
15
|
-
"react-native": "dist/global-ponyfill.js",
|
|
16
14
|
"types": "dist/index.d.ts",
|
|
17
|
-
"denoify": {
|
|
18
|
-
"index": "dist/deno-ponyfill.ts"
|
|
19
|
-
},
|
|
20
15
|
"dependencies": {
|
|
21
16
|
"@peculiar/webcrypto": "^1.4.0",
|
|
22
|
-
"@whatwg-node/node-fetch": "0.0.1
|
|
17
|
+
"@whatwg-node/node-fetch": "0.0.1",
|
|
23
18
|
"busboy": "^1.6.0",
|
|
24
19
|
"urlpattern-polyfill": "^6.0.2",
|
|
25
20
|
"web-streams-polyfill": "^3.2.1"
|
|
26
21
|
},
|
|
27
22
|
"publishConfig": {
|
|
28
23
|
"access": "public"
|
|
29
|
-
}
|
|
24
|
+
},
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"denoify": {
|
|
27
|
+
"index": "dist/deno-ponyfill.ts"
|
|
28
|
+
},
|
|
29
|
+
"react-native": "dist/global-ponyfill.js"
|
|
30
30
|
}
|