As Victor pointed out, the express prototype is in express/lib/application.js . This file is used to create an expression and is exported through the application namespace in express/lib/express.js . Therefore, using express.appliction.listen you can reference the .listen function.
You can use this method: (similar to Victor method)
var express = require('express'); express.application._listen = express.application.listen; express.application.listen = function(callback) { return this._listen(options.port, options.host, callback); };
You can also use the Lo-dash _.wrap if you do not want to store the base function yourself in a variable. It will look something like this:
var express = require('express'); var _ = require('lodash'); express.application.listen = _.wrap(express.application.listen, function(listenFn) { return listenFn(options.port, options.host, callback);
However, using these methods, you will encounter the problems that you mentioned in your question (lifting variable, creating an additional variable). To solve this problem, I usually created my own subclass of express.application and replaced the .listen function in this subclass and suggested that expression use this subclass. However, due to the explicit structure of the current, you cannot replace express.application with your own subclass without overriding the express() function itself.
Therefore, I would do to take express.application.listen completely, since this is only 2 lines. It is pretty simple!
var express = require('express'); var http = require('http'); express.application.listen = function(callback) { return http.createServer(this).listen(options.port, options.host, callback); };
You can even make the https option!
var express = require('express'); var http = require('http'); var https = require('https'); express.application.listen = function(callback) { return (options.https ? http.createServer(this) : https.createServer({ ... }, this)) .listen(options.port, options.host, callback); };
Note. One other answer mentions the expression forking and its modification. I would have a hard time justifying this for such a small function.