Skip to content

Commit

Permalink
feat: add new test for increased coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Animesh Pathak <[email protected]>
  • Loading branch information
Sonichigo committed Feb 5, 2025
1 parent 57bbb8b commit af2efe0
Show file tree
Hide file tree
Showing 7 changed files with 6,159 additions and 2,879 deletions.
6 changes: 5 additions & 1 deletion lib/middleware/body-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ module.exports = (req, res, next) => {
req.multiPartData = [];
req.multiPartParams = [];

if (!parameters.boundary) {
return next(new Error("Boundary required for multipart form-data"));
}

// parse a file upload
const dice = new Dicer({
boundary: parameters.boundary,
Expand Down Expand Up @@ -113,7 +117,7 @@ module.exports = (req, res, next) => {
dice.on("finish", () => {
// createa a new simple object param
req.multiPart = req.multiPartParams.map((param, index) => {
// append value to pair

param.value = req.multiPartData[index];

switch (typeof req.multiPartSimple[param.name]) {
Expand Down
7 changes: 4 additions & 3 deletions lib/middleware/error-handler.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const debug = require("debug")("mockbin");

module.exports = (err, req, res, next) => {
debug(err);
debug(err);

res.status(err.status || 500).view = "error";
const status = err?.status || 500;
res.status(status).view = "error";

next();
next();
};
Loading

0 comments on commit af2efe0

Please sign in to comment.