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

bricks

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bricks - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

test/injection-test.js

36

lib/appserver.js

@@ -51,5 +51,11 @@ (function () {

} else {
if (call.name !== undefined) {
options.routeName = call.name;
}
if (call.init !== undefined) {
options.appServer = this;
call.init(options);
}
if (call.plugin !== undefined) {

@@ -62,15 +68,31 @@ options.call = call.plugin;

case 'pre':
this.pre.push(options);
if (options.top === true) {
this.pre.unshift(options);
} else {
this.pre.push(options);
}
break;
case 'post':
this.post.push(options);
if (options.top === true) {
this.post.unshift(options);
} else {
this.post.push(options);
}
break;
case 'final':
this.final.push(options);
if (options.top === true) {
this.final.unshift(options);
} else {
this.final.push(options);
}
break;
default:
this.main.push(options);
if (options.top === true) {
this.main.unshift(options);
} else {
this.main.push(options);
}
}

@@ -98,3 +120,7 @@

}
if (typeof(this.options.callRoute) === 'function') {
res.callRoute = this.options.callRoute;
}
for (var i = 0; i < this.eventHandlers.length; i++) {

@@ -101,0 +127,0 @@ res.on(this.eventHandlers[i].event, this.eventHandlers[i].handler);

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

};
exports.name = 'default 404 handler';
})();

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

};
exports.name = 'default logger';
})();

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

exports.name = 'default file handler';
exports.init = function (options) {

@@ -11,0 +13,0 @@ options = options || { };

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

exports.name = 'default redirect handler';
exports.init = function (options) {

@@ -8,0 +10,0 @@ routes = options.routes;

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

exports.name = 'default session handler';

@@ -8,0 +9,0 @@ exports.plugin = function (request, response, options) {

9

lib/response.js

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

this.checkRoute = this.defaultCheckRoute;
this.callRoute = this.defaultCallRoute;
}

@@ -53,2 +54,6 @@

Response.prototype.defaultCallRoute = function (func, request, response, options) {
func(request, response, options);
};
Response.prototype.next = function () {

@@ -72,3 +77,3 @@ if (this._croute >= this._routes.length) {

try {
next.call(this._actual.request, this, next);
this.callRoute(next.call, this._actual.request, this, next);
} catch (error) {

@@ -107,3 +112,3 @@ this.emit('run.fatal', error);

if (this._croute === 2) {
if (this._croute === 3) {
var length = 0;

@@ -110,0 +115,0 @@

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

"description": "Bricks Application Server",
"version": "1.0.5",
"version": "1.0.6",
"homepage": "http://bricksjs.com/",

@@ -20,5 +20,5 @@ "preferGlobal": "true",

"cookies": "~0.1.6",
"mime": "~1.2.2",
"mime": ">=1.2.2",
"date-utils": ">1.0.0",
"optimist": "~0.2",
"optimist": ">=0.2",
"node-uuid": "~1.1.0",

@@ -28,3 +28,3 @@ "eventemitter2": "~0.2.6"

"devDependencies": {
"vows": "~0.5.0"
"vows": ">=0.5.0"
},

@@ -31,0 +31,0 @@ "directories": {

var vows = require('vows'),
assert = require('assert'),
server = require('../lib/appserver');
server = require('../lib/appserver'),
mrequest = require('./mocks/request'),
mresponse = require('./mocks/response');

@@ -74,3 +77,199 @@ vows.describe('Add Routes').addBatch({

}
},
'a route added to pre as top': {
topic: function () {
var thisp = this;
var appserver = new server.appserver({ checkRoute: function () { return true; } });
appserver.addRoute(".+", function (request, response, options) {
thisp.callback('wrong one');
}, { section: "pre" });
appserver.addRoute(".+", function (request, response, options) {
thisp.callback("ok");
}, { section: "pre", top: true });
var res = new mresponse.response();
var req = new mrequest.request();
req.url = "/bar";
appserver.handleRequest(req, res, appserver);
},
'fires in the correct order': function (err, request, response, options) {
assert.equal(err, "ok");
}
},
'a route added to main as top': {
topic: function () {
var thisp = this;
var appserver = new server.appserver({ checkRoute: function () { return true; } });
appserver.addRoute(".+", function (request, response, options) {
thisp.callback('wrong one');
}, { section: "main" });
appserver.addRoute(".+", function (request, response, options) {
thisp.callback("ok");
}, { section: "main", top: true });
var res = new mresponse.response();
var req = new mrequest.request();
req.url = "/bar";
appserver.handleRequest(req, res, appserver);
},
'fires in the correct order': function (err, request, response, options) {
assert.equal(err, "ok");
}
},
'a route added to post as top': {
topic: function () {
var thisp = this;
var appserver = new server.appserver({ checkRoute: function () { return true; } });
appserver.addRoute(".+", function (request, response, options) {
thisp.callback('wrong one');
}, { section: "post" });
appserver.addRoute(".+", function (request, response, options) {
thisp.callback("ok");
}, { section: "post", top: true });
var res = new mresponse.response();
var req = new mrequest.request();
req.url = "/bar";
appserver.handleRequest(req, res, appserver);
},
'fires in the correct order': function (err, request, response, options) {
assert.equal(err, "ok");
}
},
'a route added to final as top': {
topic: function () {
var thisp = this;
var appserver = new server.appserver({ checkRoute: function () { return true; } });
appserver.addRoute(".+", function (request, response, options) {
thisp.callback('wrong one');
}, { section: "final" });
appserver.addRoute(".+", function (request, response, options) {
thisp.callback("ok");
}, { section: "final", top: true });
var res = new mresponse.response();
var req = new mrequest.request();
req.url = "/bar";
appserver.handleRequest(req, res, appserver);
},
'fires in the correct order': function (err, request, response, options) {
assert.equal(err, "ok");
}
},
'a route added to pre': {
topic: function () {
var thisp = this;
var appserver = new server.appserver({ checkRoute: function () { return true; } });
appserver.addRoute(".+", function (request, response, options) {
try {
response.write('test');
thisp.callback("ok");
} catch (error) {
thisp.callback("error");
}
}, { section: "pre" });
var res = new mresponse.response();
var req = new mrequest.request();
req.url = "/bar";
appserver.handleRequest(req, res, appserver);
},
'can write without error': function (err, request, response, options) {
assert.equal(err, "ok");
}
},
'a route added to main': {
topic: function () {
var thisp = this;
var appserver = new server.appserver({ checkRoute: function () { return true; } });
appserver.addRoute(".+", function (request, response, options) {
try {
response.write('test');
thisp.callback("ok");
} catch (error) {
thisp.callback("error");
}
}, { section: "main" });
var res = new mresponse.response();
var req = new mrequest.request();
req.url = "/bar";
appserver.handleRequest(req, res, appserver);
},
'can write without error': function (err, request, response, options) {
assert.equal(err, "ok");
}
},
'a route added to post': {
topic: function () {
var thisp = this;
var appserver = new server.appserver({ checkRoute: function () { return true; } });
appserver.addRoute(".+", function (request, response, options) {
try {
response.write('test');
thisp.callback("ok");
} catch (error) {
thisp.callback("error");
}
}, { section: "post" });
var res = new mresponse.response();
var req = new mrequest.request();
req.url = "/bar";
appserver.handleRequest(req, res, appserver);
},
'can write without error': function (err, request, response, options) {
assert.equal(err, "ok");
}
},
'a route added to final': {
topic: function () {
var thisp = this;
var appserver = new server.appserver({ checkRoute: function () { return true; } });
appserver.addRoute(".+", function (request, response, options) {
try {
response.write('test');
thisp.callback("ok");
} catch (error) {
thisp.callback("error");
}
}, { section: "final" });
var res = new mresponse.response();
var req = new mrequest.request();
req.url = "/bar";
appserver.handleRequest(req, res, appserver);
},
'cannot write without error': function (err, request, response, options) {
assert.equal(err, "error");
}
}
}).export(module);

@@ -89,5 +89,2 @@ var vows = require('vows'),

// appserver.addRoute(".+", function (request, response, options) {
// thisp.callback(undefined, request, response, options);
// });
setTimeout(function() { thisp.callback('callback not fired'); }, 50);

@@ -94,0 +91,0 @@ var res = new mresponse.response();

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