@whatwg-node/server 0.4.10 → 0.4.12

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.
Files changed (3) hide show
  1. package/index.js +4 -9
  2. package/index.mjs +4 -9
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -145,8 +145,8 @@ async function sendNodeResponse({ headers, status, statusText, body }, serverRes
145
145
  }
146
146
  else if (isReadable(body)) {
147
147
  serverResponse.once('close', () => {
148
- resolve();
149
148
  body.destroy();
149
+ resolve();
150
150
  });
151
151
  body.pipe(serverResponse);
152
152
  }
@@ -230,12 +230,7 @@ RequestCtor = fetch.Request) {
230
230
  event.respondWith(response$);
231
231
  }
232
232
  function handleRequestWithWaitUntil(request, ...ctx) {
233
- var _a;
234
233
  const serverContext = ctx.length > 1 ? Object.assign({}, ...ctx) : ctx[0] || {};
235
- if ('process' in globalThis && ((_a = process.versions) === null || _a === void 0 ? void 0 : _a['bun']) != null) {
236
- // This is required for bun
237
- request.text();
238
- }
239
234
  if (!('waitUntil' in serverContext)) {
240
235
  const waitUntilPromises = [];
241
236
  const response$ = handleRequest(request, {
@@ -255,9 +250,9 @@ RequestCtor = fetch.Request) {
255
250
  if (typeof input === 'string' || input instanceof URL) {
256
251
  const [initOrCtx, ...restOfCtx] = maybeCtx;
257
252
  if (isRequestInit(initOrCtx)) {
258
- return handleRequestWithWaitUntil(new RequestCtor(input.toString(), initOrCtx), ...restOfCtx);
253
+ return handleRequestWithWaitUntil(new RequestCtor(input, initOrCtx), ...restOfCtx);
259
254
  }
260
- return handleRequestWithWaitUntil(new RequestCtor(input.toString()), ...maybeCtx);
255
+ return handleRequestWithWaitUntil(new RequestCtor(input), ...maybeCtx);
261
256
  }
262
257
  return handleRequestWithWaitUntil(input, ...maybeCtx);
263
258
  };
@@ -271,7 +266,7 @@ RequestCtor = fetch.Request) {
271
266
  return requestListener(input, initOrCtxOrRes, ...restOfCtx);
272
267
  }
273
268
  if (isServerResponse(initOrCtxOrRes)) {
274
- throw new Error('Got Node response without Node request');
269
+ throw new TypeError('Got Node response without Node request');
275
270
  }
276
271
  // Is input a container object over Request?
277
272
  if (typeof input === 'object' && 'request' in input) {
package/index.mjs CHANGED
@@ -141,8 +141,8 @@ async function sendNodeResponse({ headers, status, statusText, body }, serverRes
141
141
  }
142
142
  else if (isReadable(body)) {
143
143
  serverResponse.once('close', () => {
144
- resolve();
145
144
  body.destroy();
145
+ resolve();
146
146
  });
147
147
  body.pipe(serverResponse);
148
148
  }
@@ -226,12 +226,7 @@ RequestCtor = Request) {
226
226
  event.respondWith(response$);
227
227
  }
228
228
  function handleRequestWithWaitUntil(request, ...ctx) {
229
- var _a;
230
229
  const serverContext = ctx.length > 1 ? Object.assign({}, ...ctx) : ctx[0] || {};
231
- if ('process' in globalThis && ((_a = process.versions) === null || _a === void 0 ? void 0 : _a['bun']) != null) {
232
- // This is required for bun
233
- request.text();
234
- }
235
230
  if (!('waitUntil' in serverContext)) {
236
231
  const waitUntilPromises = [];
237
232
  const response$ = handleRequest(request, {
@@ -251,9 +246,9 @@ RequestCtor = Request) {
251
246
  if (typeof input === 'string' || input instanceof URL) {
252
247
  const [initOrCtx, ...restOfCtx] = maybeCtx;
253
248
  if (isRequestInit(initOrCtx)) {
254
- return handleRequestWithWaitUntil(new RequestCtor(input.toString(), initOrCtx), ...restOfCtx);
249
+ return handleRequestWithWaitUntil(new RequestCtor(input, initOrCtx), ...restOfCtx);
255
250
  }
256
- return handleRequestWithWaitUntil(new RequestCtor(input.toString()), ...maybeCtx);
251
+ return handleRequestWithWaitUntil(new RequestCtor(input), ...maybeCtx);
257
252
  }
258
253
  return handleRequestWithWaitUntil(input, ...maybeCtx);
259
254
  };
@@ -267,7 +262,7 @@ RequestCtor = Request) {
267
262
  return requestListener(input, initOrCtxOrRes, ...restOfCtx);
268
263
  }
269
264
  if (isServerResponse(initOrCtxOrRes)) {
270
- throw new Error('Got Node response without Node request');
265
+ throw new TypeError('Got Node response without Node request');
271
266
  }
272
267
  // Is input a container object over Request?
273
268
  if (typeof input === 'object' && 'request' in input) {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@whatwg-node/server",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "description": "Fetch API compliant HTTP Server adapter",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
7
  "@types/node": "^18.0.6"
8
8
  },
9
9
  "dependencies": {
10
- "@whatwg-node/fetch": "0.4.6",
10
+ "@whatwg-node/fetch": "0.4.7",
11
11
  "tslib": "^2.3.1"
12
12
  },
13
13
  "repository": {