mirror of
https://github.com/denoland/deno.git
synced 2025-03-09 21:57:40 -04:00
registerDeclarativeServer change
This commit is contained in:
parent
285635daa6
commit
6e0872c1f6
2 changed files with 7 additions and 2 deletions
|
@ -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);
|
||||
|
|
0
tests/specs/serve/declarative_server_test.ts
Normal file
0
tests/specs/serve/declarative_server_test.ts
Normal file
Loading…
Add table
Reference in a new issue