Comparing version 0.3.0 to 0.4.0
28
index.js
@@ -24,3 +24,3 @@ /** | ||
module.exports = requestbody; | ||
module.exports = requestbody; | ||
@@ -63,7 +63,7 @@ /** | ||
}; | ||
}; | ||
} | ||
/** | ||
* Donable formidable | ||
* | ||
* | ||
* @param {Stream} ctx | ||
@@ -77,7 +77,19 @@ * @param {Object} opts | ||
var form = new forms.IncomingForm(opts) | ||
form.parse(ctx.req, function(err, fields, files) { | ||
if (err) return done(err) | ||
done(null, {fields: fields, files: files}) | ||
}) | ||
} | ||
var fields = {}; | ||
var files = {}; | ||
form | ||
.on('end', function() { | ||
done(null, {fields: fields, files: files}); | ||
}) | ||
.on('error', function(err) { | ||
done(err); | ||
}) | ||
.on('field', function(field, value) { | ||
fields[field] = value; | ||
}) | ||
.on('file', function(field, file) { | ||
files[field] = file; | ||
}); | ||
form.parse(ctx.req); | ||
}; | ||
} |
{ | ||
"name": "koa-body", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "A koa body parser middleware. Support multipart, urlencoded and json request bodies.", | ||
@@ -5,0 +5,0 @@ "main": "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
9078
83