docs: add JSDoc to the public API - #1467
Conversation
Document multer(options), the middleware methods, the storage engines and MulterError, including the options and error codes added in 2.3.0. Co-authored-by: Arham Sayyed <arhamsayyed56@gmail.com>
kilisamemarisaaa
left a comment
There was a problem hiding this comment.
The File typedef does not match the object passed to the two public callbacks that reference it. File.size is currently required and stream is absent, but fileFilter runs before either property exists, and StorageEngine._handleFile receives file.stream while size is still absent.
I verified the lifecycle with a custom storage engine on the current implementation:
fileFilter: stream=false, size=false
_handleFile: stream=true, size=false
req.file: stream=false, size=true
This also conflicts with the _handleFile description here ("Consumes file.stream") and with StorageEngine.md, while editor/type consumers would report the real storage-engine API as missing. Could the callback inputs use stage-specific typedefs (for example a base incoming file plus a storage file with stream), or otherwise make size optional and declare stream for the _handleFile parameter?
Adds JSDoc to the public surface:
multer(options)with the current option set (dest/storage,fileFilter,limitsincl.fieldNestingDepthandfieldArrayIndexLimit,preservePath,defParamCharset),.single/.array/.fields/.none/.any,diskStorage/memoryStorage, the storage-engine contract andMulterError(code,field,filename, list of codes). Internals are left as they are.Supersedes #1284, which documented the 2.0 code and needed a rewrite after 2.3.0; its author is credited as co-author.
Closes #1284
Closes #1283