From 00a44c52ad212377a6e45f792c5a0d3d8f33356d Mon Sep 17 00:00:00 2001 From: Tiago de Paula Date: Thu, 30 Oct 2025 04:45:32 -0300 Subject: [PATCH] chore(deps): update @fastify/busboy to v3 Proper type for `BusboyFileStream` (fastify/busboy#51). --- package.json | 2 +- server/plugins/uploader.ts | 26 +++++++++----------------- yarn.lock | 15 ++++----------- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index a7a124b3..5b25fd9b 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "./public/**" ], "dependencies": { - "@fastify/busboy": "^1.2.1", + "@fastify/busboy": "^3.2.0", "bcryptjs": "^3.0.3", "chalk": "^4.1.2", "cheerio": "~1.0.0", diff --git a/server/plugins/uploader.ts b/server/plugins/uploader.ts index 9f6c55bd..e53c40f5 100644 --- a/server/plugins/uploader.ts +++ b/server/plugins/uploader.ts @@ -1,5 +1,5 @@ import Config from "../config"; -import busboy, {BusboyHeaders} from "@fastify/busboy"; +import busboy, {BusboyFileStream, BusboyHeaders} from "@fastify/busboy"; import {v4 as uuidv4} from "uuid"; import path from "path"; import fs from "fs"; @@ -234,19 +234,7 @@ class Uploader { busboyInstance.on( "file", - ( - fieldname: any, - fileStream: { - on: ( - arg0: string, - arg1: {(err: any): Response>; (): void} - ) => void; - unpipe: (arg0: any) => void; - read: {bind: (arg0: any) => any}; - pipe: (arg0: any) => void; - }, - filename: string | number | boolean - ) => { + (fieldname: string, fileStream: BusboyFileStream, filename: string) => { uploadUrl = `${randomName}/${encodeURIComponent(filename)}`; if (Config.values.fileUpload.baseUrl) { @@ -257,17 +245,21 @@ class Uploader { // if the busboy data stream errors out or goes over the file size limit // abort the processing with an error - // @ts-expect-error Argument of type '(err: any) => Response>' is not assignable to parameter of type '{ (err: any): Response>; (): void; }'.ts(2345) fileStream.on("error", abortWithError); fileStream.on("limit", () => { - fileStream.unpipe(streamWriter); + if (streamWriter) { + fileStream.unpipe(streamWriter); + } + fileStream.on("readable", fileStream.read.bind(fileStream)); return abortWithError(Error("File size limit reached")); }); // Attempt to write the stream to file - fileStream.pipe(streamWriter); + if (streamWriter) { + fileStream.pipe(streamWriter); + } } ); diff --git a/yarn.lock b/yarn.lock index e453624a..472ccb84 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1275,12 +1275,10 @@ resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.1.tgz#de633db3ec2ef6a3c89e2f19038063e8a122e2c2" integrity sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q== -"@fastify/busboy@^1.2.1": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-1.2.1.tgz#9c6db24a55f8b803b5222753b24fe3aea2ba9ca3" - integrity sha512-7PQA7EH43S0CxcOa9OeAnaeA0oQ+e/DHNPZwSQM9CQHW76jle5+OvLdibRp/Aafs9KXbLhxyjOTkRjWUbQEd3Q== - dependencies: - text-decoding "^1.0.0" +"@fastify/busboy@^3.2.0": + version "3.2.0" + resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-3.2.0.tgz#13ed8212f3b9ba697611529d15347f8528058cea" + integrity sha512-m9FVDXU3GT2ITSe0UaMA5rU3QkfC/UXtCU8y0gSN/GugTqtVldOBWIB5V6V3sbmenVZUIpU6f+mPEO2+m5iTaA== "@fortawesome/fontawesome-free@^7.1.0": version "7.1.0" @@ -7972,11 +7970,6 @@ test-exclude@^6.0.0: glob "^7.1.4" minimatch "^3.0.4" -text-decoding@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/text-decoding/-/text-decoding-1.0.0.tgz#38a5692d23b5c2b12942d6e245599cb58b1bc52f" - integrity sha512-/0TJD42KDnVwKmDK6jj3xP7E2MG7SHAOG4tyTgyUCRPdHwvkquYNLEQltmdMa3owq3TkddCVcTsoctJI8VQNKA== - text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"