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

mvcjs

Package Overview
Dependencies
Maintainers
1
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mvcjs - npm Package Compare versions

Comparing version 0.1.0-alpha to 0.1.0-alpha-1

.gitmodules

7

framework/bootstrap.js

@@ -45,3 +45,2 @@ "use strict";

requestHooks,
faviconHandler,
Request,

@@ -114,3 +113,3 @@ filePath;

if (!component.has('hooks/request')) {
requestHooks = component.set('hooks/request', {});
component.set('hooks/request', {});
}

@@ -125,6 +124,2 @@ // set favicon path

}
// get favicon handler
faviconHandler = component.get('core/favicon');
// hook favicon
requestHooks.set('/favicon.ico', faviconHandler.onRequest.bind(faviconHandler));
// load config

@@ -131,0 +126,0 @@ if (Type.isString(env.config)) {

@@ -12,4 +12,10 @@ {

"core/logger",
"cache/memory"
"cache/memory",
"hooks/request"
],
"core/assets": [
"core/logger",
"cache/memory",
"hooks/request"
],
"core/view": [

@@ -16,0 +22,0 @@ "core/logger"

@@ -9,2 +9,3 @@ "use strict";

logger = component.get('core/logger'),
hook = component.get('hooks/request'),
fs = di.load('fs'),

@@ -25,4 +26,3 @@ Favicon;

buffer: Type.OBJECT,
config: Type.OBJECT,
isShown: Type.BOOLEAN
config: Type.OBJECT
}, {

@@ -33,5 +33,5 @@ _construct: function Favicon_construct(config) {

}, config);
this.isShown = false;
this.readFile();
logger.print('Favicon.construct', config);
hook.add(/\/favicon\.ico$/, this.onRequest.bind(this));
},

@@ -38,0 +38,0 @@ /**

@@ -6,2 +6,4 @@ {

"db/mongo": "@{framework}/db/mongo",
"core/assets": "@{framework}/core/assets",
"core/favicon": "@{framework}/core/favicon",

@@ -8,0 +10,0 @@ "core/http": "@{framework}/core/http",

@@ -36,4 +36,9 @@ "use strict";

throw new error.DataError({key: key, value: value}, "RequestHooks.add hook value must be function type");
} else if (!Type.isRegExp(key)) {
throw new error.DataError({key: key, value: value}, "RequestHooks.add hook key must be regex type");
}
this.hooks[key] = value;
this.hooks.push({
key: key,
func: value
});
logger.print('RequestHooks.add', key, value.toString());

@@ -44,12 +49,14 @@ },

* @author Igor Ivanovic
* @method RequestHooks#has
* @method RequestHooks#get
*
* @description
* Has a hook
* Get hook
* @return {object}
*/
get: function RequestHooks_get(key) {
if (this.has(key)) {
return this.hooks[key];
get: function RequestHooks_get(value) {
var hook = this.match(value);
if (!!hook) {
return hook;
}
throw new error.HttpError(500, {key: key}, "RequestHooks.get hook not found");
throw new error.HttpError(500, {value: value}, "RequestHooks.get hook not found");
},

@@ -59,9 +66,12 @@ /**

* @author Igor Ivanovic
* @method RequestHooks#has
* @method RequestHooks#match
*
* @description
* Has a hook
* Match
* @return {boolean}
*/
has: function RequestHooks_has(key) {
return this.hooks.hasOwnProperty(key);
match: function RequestHooks_match(value) {
return this.hooks.filter(function (item) {
return item.key.test(value);
}).shift();
},

@@ -71,11 +81,15 @@ /**

* @author Igor Ivanovic
* @method RequestHooks#remove
* @method RequestHooks#has
*
* @description
* Remove hook
* Has a hook
* @return {boolean}
*/
remove: function RequestHooks_remove(key) {
if (this.has(key)) {
delete this.hooks[key];
has: function RequestHooks_has(regex) {
if (!Type.isRegExp(regex)) {
throw new error.DataError({regex: regex}, "RequestHooks.has regex must be regex type");
}
return !!this.hooks.filter(function (item) {
return item.key.source === regex.source;
}).shift();
},

@@ -93,11 +107,15 @@ /**

logger.print('RequestHooks.process', route);
return new Promise(function (resolve) {
if (that.has(route)) {
try {
resolve(that.get(route)(api));
} catch (e) {
throw new error.HttpError(500, {hook: route}, 'Hook error', e);
return new Promise(function (resolve, reject) {
var hook;
try {
hook = that.get(route);
logger.print('RequestHooks.hook', hook);
if (!!hook) {
resolve(hook(api));
} else {
resolve(false);
}
} else {
resolve(false);
} catch (e) {
logger.print('RequestHooks.hook error', e);
reject(new error.HttpError(500, {hook: route}, 'Hook error', e));
}

@@ -104,0 +122,0 @@ });

@@ -19,7 +19,7 @@ "use strict";

RequestHooksInterface = Type.create({
hooks: Type.OBJECT
hooks: Type.ARRAY
}, {
_invoke: function RequestHooksInterface() {
this.hooks = {};
["set", "get", "has", "remove", "process"].forEach(function (method) {
this.hooks = [];
["set", "get", "has", "match", "process"].forEach(function (method) {
if (!(method in this)) {

@@ -26,0 +26,0 @@ throw new error.DataError({method: method}, 'RequestHooksInterface: missing method in Hook class');

@@ -5,3 +5,3 @@ {

"description": "Powerful lightweight mvc framework for nodejs",
"version": "0.1.0-alpha",
"version": "0.1.0-alpha-1",
"dependencies" : {

@@ -12,3 +12,4 @@ "mongoose": "3.8.x",

"static-type-js": "0.3.x",
"etag": "1.5.x"
"etag": "1.5.x",
"mime-types" : "2.0.x"
},

@@ -15,0 +16,0 @@ "devDependencies": {

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