我想扩展sailsjs以具有类似于rails strong params的东西,即
req.params.limit(["email", "password", "password_confirmation"])
我已经将它创建为附加组件,但我希望它自动附加到 request.params
添加在:
limit = function(limiters){
params = this.all();
self = Object();
limiters.forEach(function(limiter){
if(params[limiter]){
self[limiter] = params[limiter]
}
return self;
}
要求:
req.params.limit = limit;
req.params.limit(["email", "password"]);
我将如何将其作为模块添加到框架中?