express-resource
Advanced tools
Comparing version 0.2.2 to 0.2.3
0.2.3 / 2011-09-23 | ||
================== | ||
* Fixed logic to allow actions to be defined in any order [Wompt] | ||
0.2.2 / 2011-09-08 | ||
@@ -3,0 +8,0 @@ ================== |
18
index.js
@@ -16,4 +16,13 @@ | ||
, lingo = require('lingo') | ||
, en = lingo.en; | ||
, en = lingo.en | ||
, orderedActions = [ | ||
'index' // GET / | ||
,'new' // GET /new | ||
,'create' // POST / | ||
,'show' // GET /:id | ||
,'edit' // GET /edit/:id | ||
,'update' // PUT /:id | ||
,'destroy'// DEL /:id | ||
]; | ||
/** | ||
@@ -40,4 +49,5 @@ * Initialize a new `Resource` with the given `name` and `actions`. | ||
// default actions | ||
for (var key in actions) { | ||
this.mapDefaultAction(key, actions[key]); | ||
for (var i=0, key; i < orderedActions.length; i++) { | ||
key = orderedActions[i]; | ||
if (actions[key]) this.mapDefaultAction(key, actions[key]); | ||
} | ||
@@ -44,0 +54,0 @@ |
{ "name": "express-resource" | ||
, "description": "Resourceful routing for express" | ||
, "version": "0.2.2" | ||
, "version": "0.2.3" | ||
, "author": "TJ Holowaychuk <tj@vision-media.ca>" | ||
@@ -5,0 +5,0 @@ , "contributors": [ |
@@ -87,3 +87,9 @@ # Express Resource | ||
}; | ||
// or | ||
User.load = function(req, id, fn) { | ||
fn(null, users[id]); | ||
}; | ||
app.resource('users', { show: ..., load: User.load }); | ||
@@ -90,0 +96,0 @@ |
34289
865
195