Skip to content
Myr

add throwing when a non-function is passed to a route

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Thorsten Lorenz · committed by TJ Holowaychuk · parent 9bd86cd · Browse files · 2 files+33 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+33 added−3 removed

  • tests:+25 added−1 removed
  • other:+8 added−2 removed

2 files+33 added−3 removed

modified:lib/router/index.js+8 added-2 removed
241 unmodified lines
242243 // ensure path was given244 if (!path) throw new Error('Router#' + method + '() requires a path');245246 // ensure all callbacks are functions247 callbacks.forEach(function(fn){248 if ('function' == typeof fn) return;249 throw new Error('Router#' + method + '() requires all callbacks to be functions');250 });251252 // create the route253 debug('defined %s %s', method, path);254 var route = new Route(method, path, callbacks, {249 sensitive: this.caseSensitive250 , strict: this.strict255 sensitive: this.caseSensitive,256 strict: this.strict257 });258259 // add it260 (this.map[method] = this.map[method] || []).push(route);
2 unmodified lines
modified:test/Router.js+25 added-1 removed