Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Ordering bug #35

tj opened this Issue · 4 comments

3 participants

tj commented

because of Object.keys() exporting .new etc are not order independent, this is definitely a bug


This was fixed in #21


Also, when you do a custom action mapping on a resource with a show action, the show action would always be a preferred route. E.g. from tests:

    function load(id, fn) { fn(null, "User"); }
    var actions = {
      show: function(req, res){
      login: function(req, res){
      logout: function(req, res){

    var users = app.resource('users', actions, { load: load });'get', 'login', actions.login);'get', '/logout', actions.logout);

Which, when running the test, results in:

   uncaught: AssertionError: test custom route configuration. Invalid response body.
    Expected: 'logout'
    Got: 'user'
tj commented

fixed by e4e7080

@tj tj closed this

In response to jupiter's comment that custom routes can never be called, I've found a way to do it, albeit one that feels pretty hackish.

var theResource = app.resource('users'); // note that the second argument is left unspecified'get', '/login', UserController.getLogin);'post', '/login', UserController.postLogin);'get', '/logout', UserController.getLogout);
theResource = app.resource('users', UserController); // ... and here, the second argument is specified as usual

Given that it's not impossible to make this work, I don't think it's worth pushing for any kind of change in the code, at least for the time being. I'm really just providing this workaround for others who've encountered the same confusing bug. Maybe worth changing the one test that fails, though, since people treat tests as documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.