New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

salad

Package Overview
Dependencies
Maintainers
2
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

salad - npm Package Compare versions

Comparing version 0.2.18 to 0.3.0

lib/server/utils/cakefile.js

2

bower.json
{
"name": "salad",
"main": "build/salad.js",
"version": "0.2.18",
"version": "0.3.0",
"homepage": "https://github.com/komola/salad",

@@ -6,0 +6,0 @@ "authors": [

(function() {
var findit, fs, gaze, path, winston, _ref,
var domain, findit, fs, gaze, path, winston, _ref,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },

@@ -21,2 +21,4 @@ __hasProp = {}.hasOwnProperty,

domain = require("domain");
Salad.Bootstrap = (function(_super) {

@@ -103,3 +105,4 @@ __extends(Bootstrap, _super);

colorize: true,
timestamp: true
timestamp: true,
level: "error"
});

@@ -218,6 +221,20 @@ App.Logger = {};

this.metadata().app = express();
this.metadata().app.use(express.responseTime());
this.metadata().app.use(express["static"]("" + Salad.root + "/public"));
if (Salad.env === "development") {
this.metadata().app.use(express.logger("dev"));
} else if (Salad.env === "production") {
this.metadata().app.use(express.logger());
}
this.metadata().app.use(express.cookieParser());
this.metadata().app.use(express.bodyParser());
this.metadata().app.use(express.methodOverride());
this.metadata().app.use(function(req, res, next) {
var requestDomain;
requestDomain = domain.create();
requestDomain.add(req);
requestDomain.add(res);
requestDomain.on("error", next);
return requestDomain.run(next);
});
if (Salad.env === "testing") {

@@ -243,3 +260,3 @@ return cb();

_this.metadata().app.use(function(err, req, res, next) {
App.Logger.log("Error", err.stack);
console.error(err.stack);
if (Salad.env === "production") {

@@ -246,0 +263,0 @@ return res.send(500, "Internal server error!");

(function() {
var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
module.exports = {

@@ -115,3 +117,3 @@ ClassMethods: {

return this.findParent(function(err, parent) {
var collectionGetter, scope;
var collectionGetter, conditions, scope;
if (parent) {

@@ -123,4 +125,122 @@ collectionGetter = "get" + (_.capitalize(_this.resourceOptions.collectionName));

}
conditions = _this.buildConditionsFromParameters(_this.params);
scope = _this.applyConditionsToScope(scope, conditions);
return callback.call(_this, null, scope);
});
},
/*
This builds conditions by URL params. Possible condtions are:
Where:
Equality:
?title=Dishes
Greater than:
?createdAt=>2013-07-15T09:09:09.000Z
Less than:
?createdAt=<2013-07-15T09:09:09.000Z
Sorting:
?sort=createdAt,-title
This would sort ascending by createdAt and descending by title. Ascending is assumed by default
*/
buildConditionsFromParameters: function(parameters) {
var allowedWhereAttributes, conditions, key, reservedParams, value;
reservedParams = ["sort", "include", "includes", "limit", "offset", "method", "controller", "action", "format"];
allowedWhereAttributes = _.keys(App[this.resourceOptions.resourceClass].metadata().attributes);
conditions = {};
for (key in parameters) {
value = parameters[key];
if (__indexOf.call(reservedParams, key) >= 0) {
if (key === "sort") {
conditions = this._buildSortConditions(value, conditions);
}
if (key === "limit" || key === "offset") {
conditions[key] = value;
}
if (key === "includes") {
conditions = this._buildIncludesConditions(value, conditions);
}
continue;
}
if (__indexOf.call(allowedWhereAttributes, key) < 0) {
continue;
}
conditions = this._buildWhereConditions(key, value, conditions);
}
return conditions;
},
_buildSortConditions: function(paramValue, conditions) {
var firstChar, sortParams, value, _i, _len;
sortParams = paramValue.split(",");
for (_i = 0, _len = sortParams.length; _i < _len; _i++) {
value = sortParams[_i];
firstChar = value[0];
if (firstChar !== "-") {
conditions.asc || (conditions.asc = []);
conditions.asc.push(value);
} else if (firstChar === "-") {
conditions.desc || (conditions.desc = []);
conditions.desc.push(value.slice(1));
}
}
return conditions;
},
_buildIncludesConditions: function(paramValue, conditions) {
var includeParams, value, _i, _len;
includeParams = paramValue.split(",");
for (_i = 0, _len = includeParams.length; _i < _len; _i++) {
value = includeParams[_i];
conditions.includes || (conditions.includes = []);
conditions.includes.push(value);
}
return conditions;
},
_buildWhereConditions: function(key, value, conditions) {
var bindingElm, checksForEquality, firstChar;
conditions.where || (conditions.where = {});
firstChar = value[0];
checksForEquality = firstChar !== ">" && firstChar !== "<";
if (!checksForEquality) {
if (firstChar === ">") {
bindingElm = "gt";
} else {
bindingElm = "lt";
}
conditions.where[key] = {};
conditions.where[key][bindingElm] = value.slice(1);
} else {
conditions.where[key] = value;
}
return conditions;
},
applyConditionsToScope: function(scope, conditions) {
var associations, includesClassArray, key, simpleKeys, theClass, value, _i, _len, _ref, _ref1;
simpleKeys = ["limit", "offset", "where"];
for (key in conditions) {
value = conditions[key];
if (__indexOf.call(simpleKeys, key) < 0) {
includesClassArray = [];
_ref = conditions[key];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
value = _ref[_i];
if (key === "includes") {
associations = App[this.resourceOptions.resourceClass].metadata().associations;
theClass = (_ref1 = associations[value]) != null ? _ref1.model : void 0;
if (theClass) {
includesClassArray.push(theClass);
}
scope = scope.includes(includesClassArray);
}
if (key === "asc") {
scope = scope.asc(value);
}
if (key === "desc") {
scope = scope.desc(value);
}
}
} else {
scope = scope[key].apply(scope, [value]);
}
}
return scope;
}

@@ -127,0 +247,0 @@ }

@@ -21,3 +21,5 @@ (function() {

val = attributes[key];
_results.push(this.set(key, val));
if (this.hasAttribute(key)) {
_results.push(this.set(key, val));
}
}

@@ -45,2 +47,5 @@ return _results;

},
hasAttribute: function(key) {
return this.metadata().attributes[key] != null;
},
getAttributes: function() {

@@ -47,0 +52,0 @@ this.initDefaultValues();

@@ -42,2 +42,3 @@ (function() {

matching = router.first(requestPath, request.method);
matching.format || (matching.format = "html");
if (!matching) {

@@ -51,2 +52,3 @@ matching = {

controllerName = _.capitalize(matching.controller);
controllerName = "" + controllerName + "Controller";
controller = this._getMatchingController(controllerName);

@@ -73,2 +75,10 @@ if (!controller) {

function(cb) {
var line;
if (Salad.env === "testing") {
return cb();
}
line = "Dispatching request: " + controllerName + "." + matching.action + " (" + matching.format + ")";
App.Logger.log(line, controller.params);
return cb();
}, function(cb) {
return controller.runTriggers("beforeAction", cb);

@@ -96,5 +106,5 @@ }, function(cb) {

controllerName = _.capitalize(controllerName);
controller = App["" + controllerName + "Controller"];
controller = App[controllerName];
if (!controller) {
throw new Error("Could not find 'App." + controllerName + "Controller'");
throw new Error("Could not find 'App." + controllerName + "'");
}

@@ -101,0 +111,0 @@ controller = new controller;

@@ -38,2 +38,4 @@ (function() {

require("./utils/cakefile");
require("../shared/validator");

@@ -40,0 +42,0 @@

@@ -30,2 +30,12 @@ (function() {

Handlebars.registerPartial = function(file, content) {
var fileParts;
fileParts = file.split("/");
if (fileParts[1].substr(0, 1) !== "_") {
return;
}
file = file.replace(".hbs", "");
return handlebars.registerPartial(file, content);
};
Handlebars._registerPartials = function() {

@@ -46,13 +56,2 @@ var content, file, _ref, _results;

Handlebars.registerPartial = function(file, content) {
var fileParts;
console.log("Registering partial " + file);
fileParts = file.split("/");
if (fileParts[1].substr(0, 1) !== "_") {
return;
}
file = file.replace(".hbs", "");
return handlebars.registerPartial(file, content);
};
return Handlebars;

@@ -59,0 +58,0 @@

{
"name": "salad",
"main": "./index.js",
"version": "0.2.18",
"version": "0.3.0",
"description": "",

@@ -6,0 +6,0 @@ "homepage": "http://github.com/komola/salad",

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