Comparing version 0.0.78 to 0.0.79
34
api.js
@@ -32,2 +32,3 @@ var _ = require('underscore'), | ||
this.resources = []; | ||
this.resources_schemas = []; | ||
@@ -54,5 +55,35 @@ var self = this; | ||
this.resources.push({name:name, url:resource.path}); | ||
resource.schema_path = _.chain([]) | ||
.push(this.path) | ||
.push('schema/') | ||
.push(name) | ||
.join('') | ||
.value(); | ||
this.resources.push({ | ||
name:name, | ||
url:resource.path, | ||
schema: resource.schema_path | ||
}); | ||
this.resources_schemas.push({ | ||
name:name, | ||
url:resource.path, | ||
allowed_methods:resource.allowed_methods, | ||
fields:resource.show_fields(), | ||
update_fields:resource.show_update_fields(), | ||
filtering : _.map(resource.filtering || {},function(value,key) | ||
{ | ||
return { field : key, usage1: resource.path + '?' + key + '=<value>', usage2: resource.path + '?' + key + '__in=<value1>,<value2>'}; | ||
}), | ||
sorting : resource.path + "?order_by=<field1>,<field2>" | ||
}); | ||
var resource_index = this.resources.length -1; | ||
var self = this; | ||
this.app.get('/' + resource.schema_path,function(req,res){ | ||
res.json(self.resources_schemas[resource_index]); | ||
}); | ||
this.app.resource(resource.path, (function(methods){ | ||
@@ -66,2 +97,3 @@ _.each(['show', 'index', 'create', 'update', 'destroy', 'load'], function(name) { | ||
})({})); | ||
}, | ||
@@ -68,0 +100,0 @@ //Alias for register -Backword Compability |
@@ -17,2 +17,9 @@ var _ = require('underscore'), | ||
show_fields : function(){ | ||
return this.fields || _.map(this.model.schema.tree,function(value,key) | ||
{ | ||
return key; | ||
}); | ||
}, | ||
get_object:function (req, id, callback) { | ||
@@ -19,0 +26,0 @@ var query = this.model.findById(id); |
{ | ||
"name":"jest", | ||
"description":"JavaScriptational State Transfer. JS restful API layer with Mongoose based resources. Inspired by python Tastypie", | ||
"version":"0.0.78", | ||
"version":"0.0.79", | ||
"author":"Ishai Jaffe <ishai@empeeric.com>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -641,3 +641,11 @@ var _ = require('underscore'), | ||
show_fields:function(){ | ||
return this.fields || []; | ||
}, | ||
show_update_fields:function() { | ||
return this.update_fields || this.show_fields(); | ||
}, | ||
// Methods to implemenet | ||
@@ -644,0 +652,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
4443837
34834