Comparing version 0.0.2 to 0.0.3
18
index.js
@@ -7,8 +7,22 @@ 'use strict'; | ||
module.exports = function(opts){ | ||
var patchNode = (opts && opts.patchNode) || false; | ||
var patchKoa = (opts && opts.patchKoa) || true; | ||
return function *(next){ | ||
if(this.is('application/json')){ | ||
this.request.body = yield co_body.json(this); | ||
var body = yield co_body.json(this); | ||
if(patchNode){ | ||
this.req.body = body; | ||
} | ||
if(patchKoa){ | ||
this.request.body = body; | ||
} | ||
} | ||
else if(this.is('application/x-www-form-urlencoded')){ | ||
this.request.body = yield co_body.form(this); | ||
var body = yield co_body.form(this); | ||
if(patchNode){ | ||
this.req.body = body; | ||
} | ||
if(patchKoa){ | ||
this.request.body = body; | ||
} | ||
} | ||
@@ -15,0 +29,0 @@ yield next; |
{ | ||
"name": "koa-body", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Simple wrapper around co-body for koa", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,2 +6,4 @@ | ||
Doesn't support multipart | ||
## Installation | ||
@@ -15,4 +17,9 @@ | ||
TODO | ||
- patchNode | ||
Set the body parameter in the node request object `this.req.body` | ||
*defauls to false* | ||
- patchKoa | ||
Set the body parameter in the koa request object `this.request.body` | ||
*defaults to true* | ||
## Example | ||
@@ -19,0 +26,0 @@ |
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
2054
27
41