Comparing version 1.0.9 to 1.1.0
## Changes | ||
### 1.1.0 - November 27, 2011 | ||
* `addRoute()` now returns `routeId` instead of `this` - BREAKING CHANGE | ||
* added `removeRoute(routeId)` | ||
* updated to `EventEmitter2` current - BREAKING CHANGE | ||
### 1.0.9 - October 25, 2011 | ||
* removed regular expression test causing exception in 0.5.10 | ||
* ready for node.js v0.6.0, and verified working on windows | ||
### 1.0.8 - October 2, 2011 | ||
@@ -10,2 +21,1 @@ | ||
* request url parsing | ||
(function () { | ||
var url = require('url'); | ||
var http = require('http'); | ||
var uuid = require('node-uuid'); | ||
var worker = require('./response'); | ||
@@ -67,2 +67,4 @@ | ||
options._id = uuid(); | ||
switch (options.section) { | ||
@@ -101,5 +103,55 @@ case 'pre': | ||
return this; | ||
return { | ||
id: options._id, | ||
section: options.section | ||
}; | ||
}; | ||
AppServer.prototype.removeRoute = function (routeId) { | ||
if (routeId === undefined || routeId.section === undefined || routeId.id === undefined) { | ||
return false; | ||
} | ||
var findAndRemove = function (array, id) { | ||
for (var i = 0; i < array.length; i++) { | ||
if (array[i]._id === id) { | ||
return array.slice(0, i + 1).concat(array.slice(i + 2)); | ||
} | ||
} | ||
return false; | ||
}; | ||
var section; | ||
if (routeId.section === 'pre') { | ||
section = findAndRemove(this.pre, routeId.id); | ||
if (section !== false) { | ||
this.pre = section; | ||
return true; | ||
} | ||
} else if (routeId.section === 'main') { | ||
section = findAndRemove(this.main, routeId.id); | ||
if (section !== false) { | ||
this.main = section; | ||
return true; | ||
} | ||
} else if (routeId.section === 'post') { | ||
section = findAndRemove(this.post, routeId.id); | ||
if (section !== false) { | ||
this.post = section; | ||
return true; | ||
} | ||
} else if (routeId.section === 'final') { | ||
section = findAndRemove(this.final, routeId.id); | ||
if (section !== false) { | ||
this.final = section; | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
AppServer.prototype.createServer = function (server) { | ||
@@ -106,0 +158,0 @@ var thisp = this; |
@@ -5,3 +5,3 @@ { | ||
"description": "Bricks Application Server", | ||
"version": "1.0.9", | ||
"version": "1.1.0", | ||
"homepage": "http://bricksjs.com/", | ||
@@ -24,4 +24,4 @@ "preferGlobal": "true", | ||
"optimist": ">=0.2", | ||
"node-uuid": "~1.1.0", | ||
"eventemitter2": "~0.2.6" | ||
"node-uuid": ">1.1.0", | ||
"eventemitter2": ">=0.4.0" | ||
}, | ||
@@ -28,0 +28,0 @@ "devDependencies": { |
@@ -5,2 +5,4 @@ # Bricks.js | ||
[![Build Status](https://secure.travis-ci.org/JerrySievert/bricks.png)](http://travis-ci.org/JerrySievert/bricks) | ||
## Installing | ||
@@ -7,0 +9,0 @@ |
@@ -13,3 +13,3 @@ var vows = require('vows'), | ||
appserver.addEventHandler('run.fatal', function (error) { thisp.callback(undefined, error); }); | ||
appserver.addEventHandler('run.fatal', function (error) { thisp.callback(this.event, error); }); | ||
appserver.addRoute(".+", function () { foo(); }); | ||
@@ -24,3 +24,3 @@ | ||
'should result in a run.fatal event': function (err, data) { | ||
assert.equal(data, 'run.fatal'); | ||
assert.equal(err, 'run.fatal'); | ||
} | ||
@@ -33,3 +33,3 @@ }, | ||
appserver.addEventHandler('route.fatal', function (error) { thisp.callback(undefined, error); }); | ||
appserver.addEventHandler('route.fatal', function (error) { thisp.callback(this.event, error); }); | ||
appserver.addRoute(function() { foo(); }, function () { foo(); }); | ||
@@ -44,5 +44,5 @@ | ||
'should result in a route.fatal event': function (err, data) { | ||
assert.equal(data, 'route.fatal'); | ||
assert.equal(err, 'route.fatal'); | ||
} | ||
} | ||
}).export(module); | ||
}).export(module); |
@@ -14,3 +14,3 @@ var vows = require('vows'), | ||
response.on('pre.complete', function (event, response) { | ||
thisp.callback(undefined, event); | ||
thisp.callback(undefined, this.event, event); | ||
}); | ||
@@ -26,3 +26,3 @@ response.end(); | ||
}, | ||
'results from run': function (err, event) { | ||
'results from run': function (event) { | ||
assert.equal(event, 'pre.complete'); | ||
@@ -37,3 +37,3 @@ } | ||
response.on('main.complete', function (event, response) { | ||
thisp.callback(undefined, event); | ||
thisp.callback(undefined, this.event, event); | ||
}); | ||
@@ -49,3 +49,3 @@ response.end(); | ||
}, | ||
'results from run': function (err, event) { | ||
'results from run': function (event) { | ||
assert.equal(event, 'main.complete'); | ||
@@ -60,3 +60,3 @@ } | ||
response.on('post.complete', function (event, response) { | ||
thisp.callback(undefined, event); | ||
thisp.callback(undefined, this.event, event); | ||
}); | ||
@@ -72,3 +72,3 @@ response.end(); | ||
}, | ||
'results from run': function (err, event) { | ||
'results from run': function (event) { | ||
assert.equal(event, 'post.complete'); | ||
@@ -83,3 +83,3 @@ } | ||
response.on('final.complete', function (event, response) { | ||
thisp.callback(undefined, event); | ||
thisp.callback(undefined, this.event, event); | ||
}); | ||
@@ -99,2 +99,2 @@ response.end(); | ||
} | ||
}).export(module); | ||
}).export(module); |
@@ -8,3 +8,3 @@ var vows = require('vows'), | ||
vows.describe('Add Routes').addBatch({ | ||
vows.describe('Routes').addBatch({ | ||
'initial appserver': { | ||
@@ -37,2 +37,21 @@ topic: function () { | ||
}, | ||
'a route when added to pre': { | ||
topic: function () { | ||
var appserver = new server.appserver(); | ||
appserver.addRoute(".+", function () { }, { section: 'pre', added: 0 }); | ||
var route = appserver.addRoute(".+", function () { }, { section: 'pre' }); | ||
appserver.addRoute(".+", function () { }, { section: 'pre', added: 1 }); | ||
return [ appserver, route ]; | ||
}, | ||
'can be removed correctly': function (topic) { | ||
var appserver = topic[0]; | ||
assert.equal(appserver.removeRoute(topic[1]), true); | ||
var routes = appserver.getRoutes(); | ||
assert.equal(routes.length, 4); | ||
assert.equal(routes[0].length, 2); | ||
} | ||
}, | ||
'can add a route to main': { | ||
@@ -52,2 +71,21 @@ topic: function () { | ||
}, | ||
'a route when added to main': { | ||
topic: function () { | ||
var appserver = new server.appserver(); | ||
appserver.addRoute(".+", function () { }, { section: 'main', added: 0 }); | ||
var route = appserver.addRoute(".+", function () { }, { section: 'main' }); | ||
appserver.addRoute(".+", function () { }, { section: 'main', added: 1 }); | ||
return [ appserver, route ]; | ||
}, | ||
'can be removed correctly': function (topic) { | ||
var appserver = topic[0]; | ||
assert.equal(appserver.removeRoute(topic[1]), true); | ||
var routes = appserver.getRoutes(); | ||
assert.equal(routes.length, 4); | ||
assert.equal(routes[1].length, 2); | ||
} | ||
}, | ||
'can add a route to post': { | ||
@@ -67,2 +105,21 @@ topic: function () { | ||
}, | ||
'a route when added to post': { | ||
topic: function () { | ||
var appserver = new server.appserver(); | ||
appserver.addRoute(".+", function () { }, { section: 'post', added: 0 }); | ||
var route = appserver.addRoute(".+", function () { }, { section: 'post' }); | ||
appserver.addRoute(".+", function () { }, { section: 'post', added: 1 }); | ||
return [ appserver, route ]; | ||
}, | ||
'can be removed correctly': function (topic) { | ||
var appserver = topic[0]; | ||
assert.equal(appserver.removeRoute(topic[1]), true); | ||
var routes = appserver.getRoutes(); | ||
assert.equal(routes.length, 4); | ||
assert.equal(routes[2].length, 2); | ||
} | ||
}, | ||
'can add a route to final': { | ||
@@ -82,2 +139,21 @@ topic: function () { | ||
}, | ||
'a route when added to final': { | ||
topic: function () { | ||
var appserver = new server.appserver(); | ||
appserver.addRoute(".+", function () { }, { section: 'final', added: 0 }); | ||
var route = appserver.addRoute(".+", function () { }, { section: 'final' }); | ||
appserver.addRoute(".+", function () { }, { section: 'final', added: 1 }); | ||
return [ appserver, route ]; | ||
}, | ||
'can be removed correctly': function (topic) { | ||
var appserver = topic[0]; | ||
assert.equal(appserver.removeRoute(topic[1]), true); | ||
var routes = appserver.getRoutes(); | ||
assert.equal(routes.length, 4); | ||
assert.equal(routes[3].length, 2); | ||
} | ||
}, | ||
'a route added to pre as top': { | ||
@@ -279,2 +355,2 @@ topic: function () { | ||
} | ||
}).export(module); | ||
}).export(module); |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
53034
1189
88
0
2
+ Addedeventemitter2@6.4.9(transitive)
+ Addednode-uuid@1.4.8(transitive)
- Removedeventemitter2@0.2.7(transitive)
- Removednode-uuid@1.1.0(transitive)
Updatedeventemitter2@>=0.4.0
Updatednode-uuid@>1.1.0