aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/http.exports.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/http.exports.js')
-rw-r--r--src/bun.js/http.exports.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/bun.js/http.exports.js b/src/bun.js/http.exports.js
index 59e2d3483..61bb77e04 100644
--- a/src/bun.js/http.exports.js
+++ b/src/bun.js/http.exports.js
@@ -207,6 +207,7 @@ export class Server extends EventEmitter {
}
this.#options = options;
+
if (callback) this.on("request", callback);
}
@@ -232,8 +233,13 @@ export class Server extends EventEmitter {
if (typeof port === "function") {
onListen = port;
} else if (typeof port === "object") {
+ port?.signal?.addEventListener("abort", ()=> {
+ this.close();
+ });
+
host = port?.host;
port = port?.port;
+
if (typeof port?.callback === "function") onListen = port?.callback;
}
const ResponseClass = this.#options.ServerResponse || ServerResponse;