Node.js: fixing Server.listen() method.

This is required for Express framework compatibility.

This closes #418 issue on GitHub.
This commit is contained in:
Max Romanov
2020-04-08 14:44:53 +03:00
parent 792ef9d3c7
commit ce53d6bdb1

View File

@@ -451,8 +451,18 @@ Server.prototype.setTimeout = function setTimeout(msecs, callback) {
return this; return this;
}; };
Server.prototype.listen = function () { Server.prototype.listen = function (...args) {
this.unit.listen(); this.unit.listen();
const cb = args.pop();
if (typeof cb === 'function') {
this.once('listening', cb);
}
this.emit('listening');
return this;
}; };
Server.prototype.emit_request = function (req, res) { Server.prototype.emit_request = function (req, res) {