grapnel-server
Advanced tools
40
index.js
@@ -7,3 +7,3 @@ /**** | ||
* @link http://artificer.io | ||
* @version 0.1.2 | ||
* @version 0.1.3 | ||
* | ||
@@ -20,5 +20,3 @@ * Released under MIT License. See LICENSE.txt or http://opensource.org/licenses/MIT | ||
this.version = '0.1.2'; | ||
this.req = {}; | ||
this.res = {}; | ||
this.version = '0.1.3'; | ||
// HTTP Verbs | ||
@@ -38,17 +36,2 @@ ['GET', 'POST', 'PUT', 'DELETE'].forEach(function(verb){ | ||
this.bind('match', function(event, _req){ | ||
// Misc. request parameters should be congruent with Grapnel's `req` parameter conventions | ||
for(var prop in _req){ | ||
self.req[prop] = _req[prop]; | ||
} | ||
// Event property should now be accessible through the `req` property | ||
self.req.event = event; | ||
// Override next -- this is the same as default event.next() functionality except the arguments are now `req`, `res`, and `next()` | ||
event.next = function(){ | ||
return this.stack.shift().call(event, self.req, self.res, function(){ | ||
event.next.call(event); | ||
}); | ||
} | ||
}); | ||
return this; | ||
@@ -59,3 +42,3 @@ } | ||
Server.prototype.constructor = exports.constructor = Server; | ||
Server.prototype.constructor = Server; | ||
@@ -66,5 +49,16 @@ Server.prototype.start = function(){ | ||
return function(req, res){ | ||
self.req = req; | ||
self.res = res; | ||
self.navigate(req.url); | ||
self.once('match', function(event, _req){ | ||
// Misc. request parameters should be congruent with Grapnel's `req` parameter conventions | ||
for(var prop in _req){ | ||
req[prop] = _req[prop]; | ||
} | ||
// Event property should now be accessible through the `req` property | ||
req.event = event; | ||
// Override next -- this is the same as default event.next() functionality except the arguments are now `req`, `res`, and `next()` | ||
event.next = function(){ | ||
return this.stack.shift().call(event, req, res, function(){ | ||
event.next.call(event); | ||
}); | ||
} | ||
}).navigate(req.url); | ||
} | ||
@@ -71,0 +65,0 @@ } |
{ | ||
"name": "grapnel-server", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Node.js Router Framework with Named Parameter & Middleware support", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"grapnel": "^0.5.8" | ||
"grapnel": "^0.5.9" | ||
}, | ||
@@ -22,5 +22,5 @@ "repository": { | ||
"router", | ||
"named", | ||
"parameters", | ||
"named parameters", | ||
"middleware", | ||
"express", | ||
"api" | ||
@@ -27,0 +27,0 @@ ], |
10505
-0.75%52
-8.77%