resource-schema
Advanced tools
Comparing version 0.8.0 to 0.8.1
@@ -80,4 +80,9 @@ // Generated by CoffeeScript 1.8.0 | ||
ResourceSchema.prototype._getAll = function(req, res, next) { | ||
var limit, modelSelect, sendResources; | ||
if (!this._isValid(req.query, res)) { | ||
var context, limit, modelSelect, sendResources; | ||
context = { | ||
req: req, | ||
res: res, | ||
next: next | ||
}; | ||
if (!this._isValid(req.query, context)) { | ||
return; | ||
@@ -91,6 +96,3 @@ } | ||
}); | ||
return _this._applyGetters(resources, modelsFound, { | ||
req: req, | ||
res: res | ||
}).then(function() { | ||
return _this._applyGetters(resources, modelsFound, context).then(function() { | ||
res.body = resources; | ||
@@ -103,6 +105,3 @@ return next(); | ||
modelSelect = this._getModelSelectFields(req.query); | ||
return this._getMongoQuery(req.query, { | ||
req: req, | ||
res: res | ||
}).then((function(_this) { | ||
return this._getMongoQuery(req.query, context).then((function(_this) { | ||
return function(mongoQuery) { | ||
@@ -131,4 +130,9 @@ var modelQuery; | ||
return function(req, res, next) { | ||
var idValue, modelQuery, query, select; | ||
if (!_this._isValid(req.query, res)) { | ||
var context, idValue, modelQuery, query, select; | ||
context = { | ||
req: req, | ||
res: res, | ||
next: next | ||
}; | ||
if (!_this._isValid(req.query, context)) { | ||
return; | ||
@@ -154,6 +158,3 @@ } | ||
resource = _this._createResourceFromModel(modelFound, req.query.$select); | ||
return _this._applyGetters([resource], [modelFound], { | ||
req: req, | ||
res: res | ||
}).then(function() { | ||
return _this._applyGetters([resource], [modelFound], context).then(function() { | ||
res.body = resource; | ||
@@ -175,8 +176,13 @@ return next(); | ||
return function(req, res, next) { | ||
var newModelData, resource; | ||
if (!_this._isValid(req.query, res)) { | ||
var context, newModelData, resource; | ||
context = { | ||
req: req, | ||
res: res, | ||
next: next | ||
}; | ||
if (!_this._isValid(req.query, context)) { | ||
return; | ||
} | ||
resource = req.body; | ||
if (!_this._isValid(resource, res)) { | ||
if (!_this._isValid(resource, context)) { | ||
return; | ||
@@ -186,6 +192,3 @@ } | ||
newModelData = _this._createModelFromResource(resource); | ||
return _this._applySetters([resource], [newModelData], { | ||
req: req, | ||
res: res | ||
}).then(function() { | ||
return _this._applySetters([resource], [newModelData], context).then(function() { | ||
var model; | ||
@@ -215,7 +218,12 @@ model = new _this.Model(newModelData); | ||
return function(req, res, next) { | ||
var idValue, newModelData, query; | ||
if (!_this._isValid(req.query, res)) { | ||
var context, idValue, newModelData, query; | ||
context = { | ||
req: req, | ||
res: res, | ||
next: next | ||
}; | ||
if (!_this._isValid(req.query, context)) { | ||
return; | ||
} | ||
if (!_this._isValid(req.body, res)) { | ||
if (!_this._isValid(req.body, context)) { | ||
return; | ||
@@ -227,6 +235,3 @@ } | ||
query[paramId] = idValue; | ||
return _this._applySetters([req.body], [newModelData], { | ||
req: req, | ||
res: res | ||
}).then(function() { | ||
return _this._applySetters([req.body], [newModelData], context).then(function() { | ||
return _this.Model.findOneAndUpdate(query, newModelData, { | ||
@@ -260,4 +265,9 @@ upsert: true | ||
return function(req, res, next) { | ||
var idValue, query; | ||
if (!_this._isValid(req.query, res)) { | ||
var context, idValue, query; | ||
context = { | ||
req: req, | ||
res: res, | ||
next: next | ||
}; | ||
if (!_this._isValid(req.query, context)) { | ||
return; | ||
@@ -301,4 +311,4 @@ } | ||
ResourceSchema.prototype._getMongoQuery = function(requestQuery, _arg) { | ||
var d, deferred, modelQuery, queryPromises, req, res, resourceField, resourceSearchFields, value; | ||
req = _arg.req, res = _arg.res; | ||
var d, deferred, modelQuery, next, queryPromises, req, res, resourceField, resourceSearchFields, value; | ||
req = _arg.req, res = _arg.res, next = _arg.next; | ||
modelQuery = clone(this.options.defaultQuery) || {}; | ||
@@ -316,3 +326,4 @@ deferred = q.defer(); | ||
req: req, | ||
res: res | ||
res: res, | ||
next: next | ||
}, (function(_this) { | ||
@@ -388,4 +399,4 @@ return function(err, query) { | ||
ResourceSchema.prototype._applySetters = function(resources, models, _arg) { | ||
var config, d, req, res, resourceField, setPromises, _ref; | ||
req = _arg.req, res = _arg.res; | ||
var config, d, next, req, res, resourceField, setPromises, _ref; | ||
req = _arg.req, res = _arg.res, next = _arg.next; | ||
setPromises = []; | ||
@@ -400,2 +411,3 @@ _ref = this.schema; | ||
res: res, | ||
next: next, | ||
resources: resources | ||
@@ -417,4 +429,4 @@ }, function(err, results) { | ||
ResourceSchema.prototype._applyGetters = function(resources, models, _arg) { | ||
var config, getPromises, req, res, resourceField, resourceSelectFields, _ref; | ||
req = _arg.req, res = _arg.res; | ||
var config, getPromises, next, req, res, resourceField, resourceSelectFields, _ref; | ||
req = _arg.req, res = _arg.res, next = _arg.next; | ||
getPromises = []; | ||
@@ -432,2 +444,3 @@ resourceSelectFields = this._getResourceSelectFields(req.query); | ||
res: res, | ||
next: next, | ||
models: models | ||
@@ -692,4 +705,5 @@ }, function(err, results) { | ||
ResourceSchema.prototype._isValid = function(obj, res) { | ||
var key, normalizedObj, v, validateValue, value, _i, _len; | ||
ResourceSchema.prototype._isValid = function(obj, _arg) { | ||
var key, next, normalizedObj, req, res, v, validateValue, value, _i, _len; | ||
req = _arg.req, res = _arg.res, next = _arg.next; | ||
validateValue = (function(_this) { | ||
@@ -696,0 +710,0 @@ return function(key, value, res) { |
{ | ||
"name": "resource-schema", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"description": "Define schemas for RESTful resources from mongoose models, and generate middleware to GET, POST, PUT, and DELETE to those resources.", | ||
@@ -5,0 +5,0 @@ "author": "Good Eggs <open-source@goodeggs.com>", |
Sorry, the diff of this file is not supported yet
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
56847
766