Skip to content

Commit 5d07c5c

Browse files
committed
chore: replace busboy with @fastify/busboy
1 parent fcb6952 commit 5d07c5c

File tree

4 files changed

+17
-28
lines changed

4 files changed

+17
-28
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const path = require('path');
44
const processMultipart = require('./processMultipart');
55
const isEligibleRequest = require('./isEligibleRequest');
66
const { buildOptions, debugLog } = require('./utilities');
7-
const busboy = require('busboy'); // eslint-disable-line no-unused-vars
7+
const busboy = require('@fastify/busboy'); // eslint-disable-line no-unused-vars
88

99
const DEFAULT_OPTIONS = {
1010
debug: false,

lib/processMultipart.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const Busboy = require('busboy');
1+
const Busboy = require('@fastify/busboy');
22
const UploadTimer = require('./uploadtimer');
33
const fileFactory = require('./fileFactory');
44
const memHandler = require('./memHandler');
@@ -29,7 +29,7 @@ module.exports = (options, req, res, next) => {
2929

3030
// Build busboy options and init busboy instance.
3131
const busboyOptions = buildOptions(options, { headers: req.headers });
32-
const busboy = Busboy(busboyOptions);
32+
const busboy = new Busboy(busboyOptions);
3333

3434
// Close connection with specified reason and http code, default: 400 Bad Request.
3535
const closeConnection = (code, reason) => {
@@ -46,9 +46,9 @@ module.exports = (options, req, res, next) => {
4646
busboy.on('field', (field, val) => req.body = buildFields(req.body, field, val));
4747

4848
// Build req.files fields
49-
busboy.on('file', (field, file, info) => {
49+
busboy.on('file', (field, file, name, info) => {
5050
// Parse file name(cutting huge names, decoding, etc..).
51-
const {filename:name, encoding, mimeType: mime} = info;
51+
const {encoding, mimeType: mime} = info;
5252
const filename = parseFileName(options, name);
5353
// Define methods and handlers for upload process.
5454
const {

package-lock.json

Lines changed: 9 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
"lint:fix": "eslint --fix ./",
1313
"coveralls": "nyc report --reporter=text-lcov | coveralls"
1414
},
15-
"dependencies": {
16-
"busboy": "^1.6.0"
17-
},
1815
"engines": {
1916
"node": ">=12.0.0"
2017
},
@@ -30,6 +27,9 @@
3027
],
3128
"license": "MIT",
3229
"repository": "richardgirges/express-fileupload",
30+
"dependencies": {
31+
"@fastify/busboy": "^2.0.0"
32+
},
3333
"devDependencies": {
3434
"coveralls": "^3.1.1",
3535
"eslint": "^7.31.0",

0 commit comments

Comments
 (0)