Closed bobrenjc93 closed 10 years ago
I think _ref = dispatch.routes[method] || [];
on line 159 of router.js should do the trick. Thoughts?
I'm using your suggestion to correct it right now, but in any case I'm curious, given the fact that in line 269 and onwards (of the source, this is src/router.coffee) the five arrays for each of the request types nsr supports (get, post, put, patch, delete) are initialized to [], what request method was the one that triggered the exception?.
Anyway, as of v0.4.9-1 issue is fixed by adding routes['any'](a minor variation on your suggestion, that allows for example, if you expect to receive a request which method is 'mingle', if you added to your handlers via router.any%28req, res) {}, it will be that way handled.
Thanks for the observation.
:+1: thanks for the quick response
One last thing: please check v0.4.9-3, which was directly spawned by your comment, and basically it comes to this: now router object has a new method: router.any, which allows to receive requests for a uri without knowing the exact method by which it will be invoked. Hope this helps.
2013-12-27T23:15:28.136121+00:00 app[web.1]: /app/node_modules/node-simple-router/lib/router.js:160 2013-12-27T23:15:28.136650+00:00 app[web.1]: for (_i = 0, _len = _ref.length; _i < _len; _i++) { 2013-12-27T23:15:28.137123+00:00 app[web.1]: ^ 2013-12-27T23:15:28.141908+00:00 app[web.1]: TypeError: Cannot read property 'length' of undefined 2013-12-27T23:15:28.141908+00:00 app[web.1]: at Server.dispatch (/app/node_modules/node-simple-router/lib/router.js:160:31) 2013-12-27T23:15:28.141908+00:00 app[web.1]: at Server.args.(anonymous function) (/app/node_modules/nodetime/lib/core/proxy.js:131:20) 2013-12-27T23:15:28.141908+00:00 app[web.1]: at Server.EventEmitter.emit (events.js:98:17) 2013-12-27T23:15:28.141908+00:00 app[web.1]: at HTTPParser.parser.onIncoming (http.js:2108:12) 2013-12-27T23:15:28.141908+00:00 app[web.1]: at HTTPParser.parserOnHeadersComplete as onHeadersComplete 2013-12-27T23:15:28.141908+00:00 app[web.1]: at Socket.socket.ondata (http.js:1966:22) 2013-12-27T23:15:28.141908+00:00 app[web.1]: at TCP.onread (net.js:525:27)