fastify-multer
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -19,6 +19,6 @@ "use strict"; | ||
else if (options.dest) { | ||
this.storage = disk_1.default({ destination: options.dest }); | ||
this.storage = (0, disk_1.default)({ destination: options.dest }); | ||
} | ||
else { | ||
this.storage = memory_1.default(); | ||
this.storage = (0, memory_1.default)(); | ||
} | ||
@@ -57,3 +57,3 @@ this.limits = options.limits; | ||
}; | ||
return make_prehandler_1.default(setup); | ||
return (0, make_prehandler_1.default)(setup); | ||
} | ||
@@ -80,3 +80,3 @@ single(name) { | ||
}); | ||
return make_prehandler_1.default(setup); | ||
return (0, make_prehandler_1.default)(setup); | ||
} | ||
@@ -83,0 +83,0 @@ } |
@@ -23,3 +23,3 @@ "use strict"; | ||
} | ||
const multer = fastify_plugin_1.default(fastifyMulter, { | ||
const multer = (0, fastify_plugin_1.default)(fastifyMulter, { | ||
fastify: '>= 3.0.0', | ||
@@ -26,0 +26,0 @@ name: 'fastify-multer', |
import { FastifyReply, FastifyRequest } from 'fastify'; | ||
import { Setup } from '../interfaces'; | ||
declare function makePreHandler(setup: Setup): (request: FastifyRequest, _: FastifyReply, next: (err?: Error | undefined) => void) => void; | ||
declare function makePreHandler(setup: Setup): (request: FastifyRequest, _: FastifyReply, next: (err?: Error) => void) => void; | ||
export default makePreHandler; |
@@ -7,3 +7,3 @@ "use strict"; | ||
const type_is_1 = __importDefault(require("type-is")); | ||
const busboy_1 = __importDefault(require("busboy")); | ||
const busboy_1 = require("@fastify/busboy"); | ||
const xtend_1 = __importDefault(require("xtend")); | ||
@@ -22,3 +22,3 @@ const on_finished_1 = __importDefault(require("on-finished")); | ||
const rawRequest = request.raw; | ||
if (!type_is_1.default(rawRequest, ['multipart'])) { | ||
if (!(0, type_is_1.default)(rawRequest, ['multipart'])) { | ||
return next(); | ||
@@ -35,3 +35,3 @@ } | ||
try { | ||
busboy = new busboy_1.default({ | ||
busboy = new busboy_1.Busboy({ | ||
headers: rawRequest.headers, | ||
@@ -59,3 +59,3 @@ limits: limits, | ||
busboy.removeAllListeners(); | ||
on_finished_1.default(rawRequest, function () { | ||
(0, on_finished_1.default)(rawRequest, function () { | ||
next(err); | ||
@@ -78,3 +78,3 @@ }); | ||
} | ||
remove_uploaded_files_1.default(uploadedFiles, remove, function (err, storageErrors) { | ||
(0, remove_uploaded_files_1.default)(uploadedFiles, remove, function (err, storageErrors) { | ||
if (err) { | ||
@@ -103,3 +103,3 @@ return done(err); | ||
} | ||
append_field_1.default(request.body, fieldname, value); | ||
(0, append_field_1.default)(request.body, fieldname, value); | ||
}); | ||
@@ -149,3 +149,3 @@ busboy.on('file', function (fieldname, fileStream, filename, encoding, mimetype) { | ||
appender.removePlaceholder(placeholder); | ||
uploadedFiles.push(xtend_1.default(file, info)); | ||
uploadedFiles.push((0, xtend_1.default)(file, info)); | ||
return pendingWrites.decrement(); | ||
@@ -158,3 +158,3 @@ } | ||
} | ||
const fileInfo = xtend_1.default(file, info); | ||
const fileInfo = (0, xtend_1.default)(file, info); | ||
appender.replacePlaceholder(placeholder, fileInfo); | ||
@@ -161,0 +161,0 @@ uploadedFiles.push(fileInfo); |
@@ -41,4 +41,4 @@ "use strict"; | ||
} | ||
const finalPath = path_1.join(destination, filename); | ||
const outStream = fs_1.createWriteStream(finalPath); | ||
const finalPath = (0, path_1.join)(destination, filename); | ||
const outStream = (0, fs_1.createWriteStream)(finalPath); | ||
file.stream.pipe(outStream); | ||
@@ -62,3 +62,3 @@ outStream.on('error', cb); | ||
delete file.path; | ||
fs_1.unlink(path, cb); | ||
(0, fs_1.unlink)(path, cb); | ||
} | ||
@@ -65,0 +65,0 @@ } |
{ | ||
"name": "fastify-multer", | ||
"description": "Fastify plugin for handling `multipart/form-data`.", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"main": "lib/index.js", | ||
@@ -25,7 +25,7 @@ "types": "lib/", | ||
"dependencies": { | ||
"@fastify/busboy": "^1.0.0", | ||
"append-field": "^1.0.0", | ||
"busboy": "~0.3.1", | ||
"concat-stream": "^2.0.0", | ||
"fastify-plugin": "^2.0.1", | ||
"mkdirp": "^0.5.1", | ||
"mkdirp": "^1.0.4", | ||
"on-finished": "^2.3.0", | ||
@@ -36,5 +36,4 @@ "type-is": "~1.6.18", | ||
"devDependencies": { | ||
"@types/busboy": "^0.2.3", | ||
"@types/concat-stream": "^1.6.0", | ||
"@types/mkdirp": "^0.5.2", | ||
"@types/mkdirp": "^1.0.2", | ||
"@types/mocha": "~5.2.7", | ||
@@ -44,4 +43,4 @@ "@types/node": "^12.7.8", | ||
"@types/type-is": "^1.6.3", | ||
"@types/xtend": "^4.0.2", | ||
"fastify": "^3.0.2", | ||
"@types/xtend": "4.0.2", | ||
"fastify": "^3.24.1", | ||
"form-data": "^2.5.1", | ||
@@ -56,6 +55,6 @@ "fs-temp": "^1.1.2", | ||
"tslint-config-prettier": "^1.18.0", | ||
"typescript": "^4.0.2" | ||
"typescript": "^4.5.2" | ||
}, | ||
"engines": { | ||
"node": ">= 6.0.0" | ||
"node": ">=10.17.0" | ||
}, | ||
@@ -62,0 +61,0 @@ "files": [ |
import { FastifyReply, FastifyRequest } from 'fastify' | ||
import is from 'type-is' | ||
import Busboy from 'busboy' | ||
import { Busboy, BusboyHeaders } from '@fastify/busboy' | ||
import extend from 'xtend' | ||
@@ -42,7 +42,7 @@ import onFinished from 'on-finished' | ||
let busboy: busboy.Busboy | ||
let busboy: Busboy | ||
try { | ||
busboy = new Busboy({ | ||
headers: rawRequest.headers, | ||
headers: rawRequest.headers as BusboyHeaders, | ||
limits: limits, | ||
@@ -52,3 +52,3 @@ preservePath: preservePath, | ||
} catch (err) { | ||
return next(err) | ||
return next(err as Error) | ||
} | ||
@@ -55,0 +55,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
18
77782
44
+ Added@fastify/busboy@^1.0.0
+ Added@fastify/busboy@1.2.1(transitive)
+ Addedmkdirp@1.0.4(transitive)
+ Addedtext-decoding@1.0.0(transitive)
- Removedbusboy@~0.3.1
- Removedbusboy@0.3.1(transitive)
- Removeddicer@0.3.0(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedstreamsearch@0.1.2(transitive)
Updatedmkdirp@^1.0.4