express-openapi-validator
Advanced tools
Comparing version 0.52.4 to 0.53.1
@@ -14,24 +14,11 @@ "use strict"; | ||
if (err) { | ||
if (err instanceof multer.MulterError) { | ||
// TODO is special handling for MulterErrors needed | ||
console.error(err); | ||
next(errors_1.validationError(500, req.path, err.message)); | ||
} | ||
else { | ||
// HACK | ||
// TODO improve multer error handling | ||
const missingField = /Multipart: Boundary not found/i.test(err.message || ''); | ||
if (missingField) { | ||
next(errors_1.validationError(400, req.path, 'multipart file(s) required.')); | ||
} | ||
else { | ||
console.error(err); | ||
next(errors_1.validationError(500, req.path, err.message)); | ||
} | ||
} | ||
next(error(req, err)); | ||
} | ||
else { | ||
(req.files || []).forEach(f => { | ||
req.body[f.fieldname] = ''; | ||
}); | ||
if (req.files) { | ||
// add files to body | ||
req.files.forEach(f => { | ||
req.body[f.fieldname] = ''; | ||
}); | ||
} | ||
next(); | ||
@@ -58,2 +45,21 @@ } | ||
} | ||
function error(req, err) { | ||
if (err instanceof multer.MulterError) { | ||
// TODO is special handling for MulterErrors needed | ||
console.error(err); | ||
return errors_1.validationError(500, req.path, err.message); | ||
} | ||
else { | ||
// HACK | ||
// TODO improve multer error handling | ||
const missingField = /Multipart: Boundary not found/i.test(err.message || ''); | ||
if (missingField) { | ||
return errors_1.validationError(400, req.path, 'multipart file(s) required.'); | ||
} | ||
else { | ||
console.error(err); | ||
return errors_1.validationError(500, req.path, err.message); | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=openapi.multipart.js.map |
{ | ||
"name": "express-openapi-validator", | ||
"version": "0.52.4", | ||
"version": "0.53.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
868
41400