0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-09 21:57:40 -04:00

registerDeclarativeServer change

This commit is contained in:
ricfrst 2024-10-28 11:33:54 -04:00
parent 285635daa6
commit 6e0872c1f6
2 changed files with 7 additions and 2 deletions

View file

@ -862,7 +862,7 @@ internals.upgradeHttpRaw = upgradeHttpRaw;
internals.serveHttpOnListener = serveHttpOnListener;
internals.serveHttpOnConnection = serveHttpOnConnection;
function registerDeclarativeServer(exports) {
export function registerDeclarativeServer(exports) {
if (ObjectHasOwn(exports, "fetch")) {
if (typeof exports.fetch !== "function") {
throw new TypeError(
@ -882,7 +882,7 @@ function registerDeclarativeServer(exports) {
: "";
const host = formatHostName(hostname);
// deno-lint-ignore no-console
// Log server information
console.error(
`%cdeno serve%c: Listening on %chttp://${host}:${port}/%c${nThreads}`,
"color: green",
@ -891,6 +891,11 @@ function registerDeclarativeServer(exports) {
"color: inherit",
);
}
// Check if `onListen` is provided by `exports` and call it if present
if (typeof exports.onListen === "function") {
exports.onListen({ port, hostname });
}
},
handler: (req, connInfo) => {
return exports.fetch(req, connInfo);