Skip to content

Instantly share code, notes, and snippets.

@artcommacode
Created November 1, 2011 12:17
Show Gist options
  • Save artcommacode/1330404 to your computer and use it in GitHub Desktop.
Save artcommacode/1330404 to your computer and use it in GitHub Desktop.
//app.js
var users = app.resource('users', require('./controllers/users'));
users.map('get', '/login', users.login);
//users.js
exports.login = function(req, res){
res.end('login');
};
//error
TypeError: undefined is not a function
at CALL_NON_FUNCTION (native)
at /srv/www/node/ithrowu/node_modules/express-resource/index.js:152:7
at callbacks (/srv/www/node/ithrowu/node_modules/express/lib/router/index.js:272:11)
at param (/srv/www/node/ithrowu/node_modules/express/lib/router/index.js:246:11)
at param (/srv/www/node/ithrowu/node_modules/express/lib/router/index.js:243:11)
at pass (/srv/www/node/ithrowu/node_modules/express/lib/router/index.js:253:5)
at Router._dispatch (/srv/www/node/ithrowu/node_modules/express/lib/router/index.js:280:4)
at Object.handle (/srv/www/node/ithrowu/node_modules/express/lib/router/index.js:45:10)
at next (/srv/www/node/ithrowu/node_modules/express/node_modules/connect/lib/http.js:201:15)
at /srv/www/node/ithrowu/node_modules/express/node_modules/connect/lib/middleware/session.js:323:9
@artcommacode
Copy link
Author

// looks like objects don't map like i assumed they would
// this works pretty well, probably better to define the require up at top though ... maybe a better way of defining controllers?
var users = app.resource('users', require('./controllers/users'));
users.map('get', '/login', require('./controllers/users').login);

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