Skip to content

Commit

Permalink
Update openapi.multipart.ts
Browse files Browse the repository at this point in the history
Add global namespace for typing DefinitelyTyped/DefinitelyTyped#18569 (comment)
  • Loading branch information
jy95 authored Dec 2, 2019
1 parent 1d5f572 commit 22de592
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/middlewares/openapi.multipart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ function error(req: OpenApiRequest, err: Error): ValidationError {
// - 413 ( Request Entity Too Large ) : Too many parts / File too large / Too many files
// - 400 ( Bad Request ) : Field * too long / Too many fields
// - 500 ( Internal Server Error ) : Unexpected field
const multerError: multer.MulterError = err;
const multerError: Express.Multer.MulterError = err;
const payload_too_big = /LIMIT_(FILE|PART)_(SIZE|COUNT)/.test(multerError.code);
const unexpected = /LIMIT_UNEXPECTED_FILE/.test(multerError.code);
const status = (payload_too_big)
? 413
: (!unexpected)
? 400
: 500;
return validationError(500, req.path, err.message);
return validationError(status, req.path, err.message);
} else {
// HACK
// TODO improve multer error handling
Expand Down

0 comments on commit 22de592

Please sign in to comment.