I am trying to extend the behavior of app.get , but it seems that after this the application lost some configuration that I did before expanding it.
In the following snippet / sample and / es / sample, the output is empty and the expected result should be '
Am I doing something wrong?
var app = require('express')(); app.set('myprop', 'value'); var _get = app['get']; app['get'] = function (route, middleware, callback) { _get.call(app, route, middleware, callback);
UPDATE
Sorry, I will answer myself ...
I skipped the next first line in the extension method :)
if (middleware === undefined && callback === undefined) return _get.call(app, route);
Now it works like a charm!
app['get'] = function (route, middleware, callback) { if (middleware === undefined && callback === undefined) return _get.call(app, route); _get.call(app, route, middleware, callback);
source share