dat-middleware
Advanced tools
Comparing version 1.1.3 to 1.2.0
@@ -282,3 +282,18 @@ var error = require('./error'); | ||
RequestData.prototype.set = function (key, value) { | ||
return this.transform(utils.set(key, value)); | ||
return this.transform(function (data, req) { | ||
data = utils.set(key, value)(data); | ||
if (typeof key === 'object') { | ||
Object.keys(key).forEach(function (key) { | ||
if (typeof data[key] === 'string') { | ||
data[key] = keypather.get(req, data[key]) || data[key]; | ||
} | ||
}); | ||
} | ||
else { | ||
if (typeof data[key] === 'string') { | ||
data[key] = keypather.get(req, value) || value; | ||
} | ||
} | ||
return data; | ||
}); | ||
}; | ||
@@ -413,3 +428,3 @@ /** | ||
var dataType = this.dataType; | ||
req[dataType] = step.transformation(req[dataType]); | ||
req[dataType] = step.transformation(req[dataType], req); | ||
} | ||
@@ -416,0 +431,0 @@ else { |
{ | ||
"name": "dat-middleware", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "common request, response, body, query, and param validation, transformation, and flow control middleware", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -68,3 +68,2 @@ var createAppWithMiddleware = require('./fixtures/createAppWithMiddleware'); | ||
var params = dataType === 'params' ? values(data) : []; | ||
console.log('body',body); | ||
request(this.app) | ||
@@ -71,0 +70,0 @@ .post('/'+dataType, params, query) |
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
1330
51739
22