Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

crude

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crude - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

27

controller-crud.js

@@ -129,3 +129,4 @@ /**

res.locals.opts = this.opts;
res.locals.schema = this._getSchema();
var entity = new this.Entity();
res.locals.schema = entity.getSchema();
res.locals.currentUser = req.user;

@@ -140,26 +141,2 @@ // all template functions

/**
* Add fields required for the views to render properly.
*
* Render at first runtime and serve cached afterwards.
*
* @return {Object} An extended mongoose schema.
*/
CrudCtrl.prototype._getSchema = function() {
if (this._schemaViews) {
return this._schemaViews;
}
var entity = new this.Entity();
var schemaViews = this._schemaViews = Object.create(entity.Model.schema.paths);
__.forIn(schemaViews, function(schemaItem, path) {
schemaViews[path]._viewData = {
canShow: tplHelpers.canShow(schemaItem, this.opts),
name: tplHelpers.getName(path, this.opts),
};
}, this);
return schemaViews;
};
/**
* Process incoming POST vars, we will:

@@ -166,0 +143,0 @@ * * Remove all vars starting with underscore ( _ ).

5

package.json
{
"name": "crude",
"description": "Seamless CRUD control operations for node.",
"version": "0.0.13",
"version": "0.0.14",
"homepage": "https://github.com/talksession/node-crude",

@@ -40,3 +40,4 @@ "author": {

"middlewarify": "~0.0.4",
"node-entity": "0.0.5"
"node-entity": "0.0.7",
"mschema": "~0.5.2"
},

@@ -43,0 +44,0 @@ "devDependencies": {

@@ -15,2 +15,4 @@ /**

var val = item[paths.shift()];
// mongoose may have nested objects, take care of that
if (0 < paths.length) {

@@ -25,44 +27,11 @@ paths.forEach(function(p){

/**
* Return a proper label for the path.
* Return the string with the first char capitalized.
*
* @param {string} path The full path name.
* @param {Object} opts The CRUD-controller options object.
* @return {[type]} [description]
* @param {string} name The string.
* @return {string} Return the string with the first char capitalized.
*/
tplHelpers.getName = function(path, opts) {
var name;
if (opts.expandPaths) {
name = path;
} else {
name = path.split('.').pop();
}
tplHelpers.capitaliseFirstChar = function(name) {
return name.charAt(0).toUpperCase() + name.slice(1);
};
/**
* Determine if this schema item should be publicly displayed.
*
* @param {Object} schemaItem A single schema item (a column).
* @param {Object} opts The CRUD-controller options object.
* @return {boolean} true to show.
*/
tplHelpers.canShow = function(schemaItem, opts) {
// check for custom excluded paths
if (opts.viewExcludePaths.length) {
if (0 <= opts.viewExcludePaths.indexOf(schemaItem.path)) {
return false;
}
}
// check for private vars (starting with underscore)
if ('_' === schemaItem.path.charAt(0)) {
if (opts.showId && '_id' === schemaItem.path) {
return true;
}
return false;
} else {
return true;
}
};
tplHelpers.formAttrs = function() {

@@ -69,0 +38,0 @@ return {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc