visionmedia / express-resource

Resourceful routing for Express
1.41k stars 140 forks source link

Compatibility with Express 3 #55

Closed Couto closed 12 years ago

Couto commented 12 years ago

I'm currently using express 3.0.0alpha1-pre (ok, i know it's alpha) and express-resource 0.2.4 (from npm) As soon as I require express-resource i get this error:

TypeError: Cannot read property 'methods' of undefined
    at Object.<anonymous> (/home/myUser/web/myWebsite/private/node_modules/express-resource/index.js:234:15)

That line refers to the following code block

express.router.methods.concat(['del', 'all']).forEach(function(method){
  Resource.prototype[method] = function(path, fn){
    if ('function' == typeof path
      || 'object' == typeof path) fn = path, path = '';
    this.map(method, path, fn);
    return this;
  }                                                                                                                                                   
});

My main question is: Are you planning to make express-resource compatible with Express 3, if so, do you have any ETA? Thanks for your time =)

craftgear commented 12 years ago

+1 I'd like to know, too.

btw, router is now Router in express3, so above error is easy to circumvent. but again, express.HTTPServer which is not defined in express3 due to the structural change causes an error at line 252.

panosru commented 12 years ago

+1

andypham commented 12 years ago

+1

rik1shah commented 12 years ago

+1

rdrey commented 12 years ago

+1

yohjizzz commented 12 years ago

+1

forste commented 12 years ago

+1

mclark4386 commented 12 years ago

+1

clemensg commented 12 years ago

+1

express-resource for express3 would be great!

jedwood commented 12 years ago

+1

katowulf commented 12 years ago

+1

danschumann commented 12 years ago

Change router to upper case and on line 252 change express.HTTPServer.prototype to app

so it's app.resource

It's probably a flawed fix, though it works to get it running.

mclark4386 commented 12 years ago

didn't work for me... though I may not have edited it correctly

glenjamin commented 12 years ago

The latest fix for this is to add "methods" as a dependency of express-resource, and then use do

require('methods').concat(['del', 'all']).forEach(function(method){
mclark4386 commented 12 years ago

that got me past the original error, but then I hit what I think @danschumann was fixing. However I couldn't get his solution to work.

iancrowther commented 12 years ago

Tied all of the above with no joy

koenbok commented 12 years ago

+1

a1arias commented 12 years ago

+1

dangilkerson commented 12 years ago

+1

caspian311 commented 12 years ago

Is @visionmedia still working on this? It looks like the express 3 compatibility branch hasn't been touched in over a month.

tbjers commented 12 years ago

+1 extra-bump shin-kick

socialhack commented 12 years ago

+1

dangilkerson commented 12 years ago

+1 This is the only thing keeping me on express2.

joakim commented 12 years ago

I'll add my +1, but also mention that TJ started working on this last month. Check out the branch if you think you can help out.

https://github.com/visionmedia/express-resource/tree/add/express3x-support

Also, see #61. It's not as straight forward as it seems.

robdodson commented 12 years ago

+1

NachoSoto commented 12 years ago

+1

ghost commented 12 years ago

+1

realyze commented 12 years ago

+1

ghost commented 12 years ago

+1 :) Any way I can help?

a1arias commented 12 years ago

Everyone who has +1ed this issue:

Take a look at the examples "resource" and "MVC" in the express repo. It's super easy to create your own "resource" middleware. I don't think anyone should waste the time to make this module compatible with express3 because auto-loading routes for resources is already built right in (with some improvements).