From a265859e7e440685a8209fc153f660438d49b535 Mon Sep 17 00:00:00 2001 From: RJ Beers Date: Mon, 1 Jul 2024 09:41:36 -0400 Subject: [PATCH] chore(deps): remove to-readable-stream (#6685) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dependency was outdated. The latest version recommends using `node:streams` `Readable.from()` to produce a nodejs stream. Co-authored-by: Eduardo Bouças Co-authored-by: Lukas Holzer --- package-lock.json | 17 ----------------- package.json | 1 - src/utils/proxy.ts | 4 ++-- 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 62555d9dd3e..87dc0bc9d1f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -113,7 +113,6 @@ "terminal-link": "3.0.0", "through2-filter": "4.0.0", "through2-map": "4.0.0", - "to-readable-stream": "3.0.0", "toml": "3.0.0", "tomlify-j0.4": "3.0.0", "ulid": "2.3.0", @@ -21620,17 +21619,6 @@ "node": ">=4" } }, - "node_modules/to-readable-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-3.0.0.tgz", - "integrity": "sha512-vD2LytT6DxPynBa1xbMtswY9gGqj27wNbh2uvI5OhBe+mrGLurRWRQZyQn3812sqlQRtUJwaKVshG+PoGwbPDQ==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -38997,11 +38985,6 @@ "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=" }, - "to-readable-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-3.0.0.tgz", - "integrity": "sha512-vD2LytT6DxPynBa1xbMtswY9gGqj27wNbh2uvI5OhBe+mrGLurRWRQZyQn3812sqlQRtUJwaKVshG+PoGwbPDQ==" - }, "to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", diff --git a/package.json b/package.json index e10a8d24b9e..ec69a23d14a 100644 --- a/package.json +++ b/package.json @@ -173,7 +173,6 @@ "terminal-link": "3.0.0", "through2-filter": "4.0.0", "through2-map": "4.0.0", - "to-readable-stream": "3.0.0", "toml": "3.0.0", "tomlify-j0.4": "3.0.0", "ulid": "2.3.0", diff --git a/src/utils/proxy.ts b/src/utils/proxy.ts index 24ea6dc90d2..806dd526686 100644 --- a/src/utils/proxy.ts +++ b/src/utils/proxy.ts @@ -4,6 +4,7 @@ import { readFile } from 'fs/promises' import http, { ServerResponse } from 'http' import https from 'https' import { isIPv6 } from 'net' +import { Readable } from 'node:stream' import path from 'path' import process from 'process' import { Duplex } from 'stream' @@ -24,7 +25,6 @@ import { jwtDecode } from 'jwt-decode' import { locatePath } from 'locate-path' import { Match } from 'netlify-redirector' import pFilter from 'p-filter' -import toReadableStream from 'to-readable-stream' import throttle from 'lodash/throttle.js' import { BaseCommand } from '../commands/index.js' @@ -176,7 +176,7 @@ const proxyToExternalUrl = function ({ pathRewrite: () => destURL, // hide logging logLevel: 'warn', - ...(Buffer.isBuffer(req.originalBody) && { buffer: toReadableStream(req.originalBody) }), + ...(Buffer.isBuffer(req.originalBody) && { buffer: Readable.from(req.originalBody) }), }) // @ts-expect-error TS(2345) FIXME: Argument of type 'Request' is not assignable to parameter of type 'Request>'. return handler(req, res, () => {})