support for express-resource #1

yaronn opened this Issue Jun 24, 2012 · 11 comments


None yet

2 participants


express-resource is a patch on top of express that adds rest capabilities:

I'm trying to apply express-streamline but getting this error immediately on start (e.g. during the patching):

Cannot call method 'remove' of undefined
TypeError: Cannot call method 'remove' of undefined
at Resource.add (\node_modules\express-resource\index.js:188:24)


Weird, we use express-resource too and it works just fine — its implementation just calls the underlying get/post/etc. methods.

Could you paste some of your code? Thanks!


Will do tommorow. Could be related to the fact I use nested resources?


Maybe, not sure. It'd help to see the code and stack trace to see when/where specifically the error is happening.


It looks related to sub resources. My 2 files are below. Note the commented line in the first file. If you uncomment it (which is what I need for nested resources) then the server will fail on start.


express = require 'express'
require 'express-resource'
app = express.createServer()
require 'express-streamline'

proj = app.resource 'projects', require('./stub')
random = app.resource 'users/random', require('./stub')
#proj.add random

app.error (err, req, res, next) ->
    console.log("error: " + err)

app.listen 3000

console.log "listening on port 3000"


exports.index = (req, res, _) ->        
    console.log req.params
    res.end "123"

this is the error I get:

Cannot call method 'remove' of undefined
TypeError: Cannot call method 'remove' of undefined
at Resource.add (C:\Users\naveh\Documents\features\projects\oss\node_modules\express-resource\index.js:188:24)
at Object.<anonymous> (C:\Users\naveh\Documents\features\projects\oss\server._coffee:14:8)
at Object.<anonymous> (C:\Users\naveh\Documents\features\projects\oss\server._coffee:25:4)
at Module._compile (module.js:441:26)
at Object._js (C:\Users\naveh\AppData\Roaming\npm\node_modules\streamline\lib\compiler\underscored.js:28:11)
at Object.._coffee (C:\Users\naveh\AppData\Roaming\npm\node_modules\streamline\lib\compiler\underscored.js:41:17)
at (C:\Users\naveh\AppData\Roaming\npm\node_modules\streamline\lib\compiler\underscored.js:91:56)
at _run (C:\Users\naveh\AppData\Roaming\npm\node_modules\streamline\lib\compiler\command.js:77:29)
at (C:\Users\naveh\AppData\Roaming\npm\node_modules\streamline\lib\compiler\command.js:107:3)
at Object.<anonymous> (C:\Users\naveh\AppData\Roaming\npm\node_modules\streamline\bin\_coffee:7:14)

It definitely seems to be related, you're right. From the Resource::add method:

I wonder what it means to call app[method](key), i..e what the key is and what calling e.g. app.get like that does.

Thanks @yaronn, I'll investigate.


Indeed, app.get('/path') is an alias for app.lookup.get('/path'), which returns a function that has certain properties/methods, incl. remove(). This module was incorrectly expecting a handler function all the time. Fixed!

Thanks for the catch, @yaronn.

@aseemk aseemk closed this Jun 25, 2012

thanks, but I still get this error on version 0.1.2


Ah, I should be returning the return value! My bad, will fix ASAP. =)

@aseemk aseemk reopened this Jun 25, 2012

Okay, try 0.1.3 now? =)


works great. thanks for the prompt fix!

@yaronn yaronn closed this Jun 25, 2012

Great! No problem and thanks for the great bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment