cmbf-hapi-restmodel
Advanced tools
Comparing version 0.6.9 to 0.6.10
@@ -199,9 +199,3 @@ var Joi = require('joi'), | ||
var service = _this.handlers[key]; | ||
if(service) { | ||
service.Model = _this; | ||
service.data = result; | ||
service.credentials = options.credentials; | ||
return server.cmbf.service(service); | ||
} | ||
else if(_.isFunction(service)) { | ||
if(_.isFunction(service)) { | ||
return service({ | ||
@@ -214,2 +208,8 @@ Model: _this, | ||
} | ||
else if(_.isObject(service)) { | ||
service.Model = _this; | ||
service.data = result; | ||
service.credentials = options.credentials; | ||
return server.cmbf.service(service); | ||
} | ||
else { | ||
@@ -226,10 +226,3 @@ return result | ||
var service = _this.constructor.handlers[key]; | ||
if(_.isObject(service)) { | ||
service.model = _this; | ||
service.Model = _this.constructor; | ||
service.data = result; | ||
service.credentials = options.credentials; | ||
return server.cmbf.service(service); | ||
} | ||
else if(_.isFunction(service)) { | ||
if(_.isFunction(service)) { | ||
return service({ | ||
@@ -243,2 +236,9 @@ model: _this, | ||
} | ||
else if(_.isObject(service)) { | ||
service.model = _this; | ||
service.Model = _this.constructor; | ||
service.data = result; | ||
service.credentials = options.credentials; | ||
return server.cmbf.service(service); | ||
} | ||
else { | ||
@@ -293,2 +293,26 @@ return result | ||
static createValidateSpec(op) { | ||
if(this.validation[op]) { | ||
return this.validation[op]; | ||
} | ||
else { | ||
var rules = {}; | ||
if(this.schema) { | ||
var schema = this.schema.describe(); | ||
// Create validation for query | ||
// Create validation for params | ||
// Create validation for payload | ||
// Add header validation | ||
} | ||
return rules; | ||
} | ||
}; | ||
} | ||
@@ -295,0 +319,0 @@ |
@@ -38,3 +38,3 @@ var P = require('bluebird'), | ||
cache: Model.cache, | ||
validate: Model.validation.list | ||
validate: Model.createValidateSpec('list') | ||
} | ||
@@ -52,3 +52,3 @@ }); | ||
description: "Get a single "+Model.name+" instance", | ||
validate: Model.validation.show | ||
validate: Model.createValidateSpec('show') | ||
} | ||
@@ -65,3 +65,3 @@ }); | ||
description: "Create a "+Model.name+" instance", | ||
validate: Model.validation.create | ||
validate: Model.createValidateSpec('create') | ||
} | ||
@@ -78,3 +78,3 @@ }); | ||
description: "Upsert a "+Model.name+" instance", | ||
validate: Model.validation.upsert | ||
validate: Model.createValidateSpec('upsert') | ||
} | ||
@@ -91,3 +91,3 @@ }); | ||
description: "Update a "+Model.name+" instance", | ||
validate: Model.validation.update | ||
validate: Model.createValidateSpec('update') | ||
} | ||
@@ -104,3 +104,3 @@ }); | ||
description: "Remove a "+Model.name+" instance", | ||
validate: Model.validation.remove | ||
validate: Model.createValidateSpec('remove') | ||
} | ||
@@ -107,0 +107,0 @@ }); |
{ | ||
"name": "cmbf-hapi-restmodel", | ||
"version": "0.6.9", | ||
"version": "0.6.10", | ||
"author": "Joel Grenon <joelgrenon@covistra.com>", | ||
@@ -5,0 +5,0 @@ "description": "Hapi plugin building a REST Api from Joi schema, backed by covistra-mongo plugin", |
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
41846
673