@@ -4,6 +4,7 @@ import { ParsedField } from "./types/parsed-field.type";
44import { ParsedFile } from "./types/parsed-file.type" ;
55import { ParsedMultipartFormData } from "./types/parsed-multipart-form-data.type" ;
66import { Config } from "./types/config.type" ;
7+ import { IncomingHttpHeaders } from "http" ;
78
89export default async function parseMultipartFormData (
910 request : HttpRequest ,
@@ -16,34 +17,34 @@ export default async function parseMultipartFormData(
1617
1718 let busboy ;
1819 if ( options ) {
19- busboy = new Busboy ( {
20- headers : ( request . headers as unknown ) as Busboy . BusboyHeaders ,
20+ busboy = Busboy ( {
21+ headers : ( request . headers as unknown ) as IncomingHttpHeaders ,
2122 ...options ,
2223 } ) ;
2324 } else {
24- busboy = new Busboy ( {
25- headers : ( request . headers as unknown ) as Busboy . BusboyHeaders ,
25+ busboy = Busboy ( {
26+ headers : ( request . headers as unknown ) as IncomingHttpHeaders ,
2627 } ) ;
2728 }
2829
2930 busboy . on (
3031 "file" ,
31- function ( fieldname , file , filename , encoding , mimetype ) {
32+ function ( name , stream , { filename, encoding, mimeType } ) {
3233 const arrayBuffer : Buffer [ ] = [ ] ;
33- file . on ( "data" , function ( data ) {
34+ stream . on ( "data" , function ( data ) {
3435 arrayBuffer . push ( data ) ;
3536 } ) ;
3637
37- file . on ( "end" , function ( ) {
38+ stream . on ( "end" , function ( ) {
3839 const bufferFile = Buffer . concat ( arrayBuffer ) ;
3940 files . push (
4041 new Promise ( ( resolve ) => {
4142 resolve ( {
42- fieldname ,
43+ name ,
4344 bufferFile,
4445 filename,
4546 encoding,
46- mimetype ,
47+ mimeType ,
4748 } ) ;
4849 } )
4950 ) ;
@@ -54,22 +55,19 @@ export default async function parseMultipartFormData(
5455 busboy . on (
5556 "field" ,
5657 function (
57- fieldname ,
58+ name ,
5859 value ,
59- fieldnameTruncated ,
60- valueTruncated ,
61- encoding ,
62- mimetype
60+ { nameTruncated, valueTruncated, encoding, mimeType }
6361 ) {
6462 fields . push (
6563 new Promise ( ( resolve ) => {
6664 resolve ( {
67- fieldname ,
65+ name ,
6866 value,
69- fieldnameTruncated ,
67+ nameTruncated ,
7068 valueTruncated,
7169 encoding,
72- mimetype ,
70+ mimeType ,
7371 } ) ;
7472 } )
7573 ) ;
0 commit comments