aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-05-17 11:37:34 +0000
committerFuwn <[email protected]>2022-05-17 11:37:34 +0000
commit1093a71896ff02a7034696990078054ae3a8020d (patch)
tree4c81fbdc11a844b77cbe5f3f36c04ab51fe405e8
parentrefactor(server): make ctx explicitly optional (diff)
downloadlaurali-1093a71896ff02a7034696990078054ae3a8020d.tar.xz
laurali-1093a71896ff02a7034696990078054ae3a8020d.zip
fix(server): re-static #hostname and #port
-rw-r--r--examples/my_cool_server.ts2
-rw-r--r--laurali/server.ts16
2 files changed, 9 insertions, 9 deletions
diff --git a/examples/my_cool_server.ts b/examples/my_cool_server.ts
index 3cf3b6d..793e01f 100644
--- a/examples/my_cool_server.ts
+++ b/examples/my_cool_server.ts
@@ -72,7 +72,7 @@ class MyCoolServer extends Server {
override onListen() {
MyCoolServer.logger.info(
- `Listening on ${this.hostname}:${this.port}.`,
+ `Listening on ${MyCoolServer.hostname}:${MyCoolServer.port}.`,
);
}
}
diff --git a/laurali/server.ts b/laurali/server.ts
index e6706b4..b647dc2 100644
--- a/laurali/server.ts
+++ b/laurali/server.ts
@@ -39,9 +39,9 @@ export abstract class Server {
/** All registered hook functions of the `Server` */
static #hooks: Map<Hook, (ctx: Deno.TlsConn) => void> = new Map();
/** The port of the `Server` */
- #port: number;
+ static #port: number;
/** The hostname of the `Server` */
- #hostname: string;
+ static #hostname: string;
/**
* @param certFile The path to the public key file of the `Server`
@@ -56,8 +56,8 @@ export abstract class Server {
const port = config?.port || 1965;
const hostname = config?.hostname || "0.0.0.0";
- this.#port = port;
- this.#hostname = hostname;
+ Server.#port = port;
+ Server.#hostname = hostname;
this.#listener = Deno.listenTls({
port,
@@ -78,13 +78,13 @@ export abstract class Server {
}
/** Get the `port` of the `Server` */
- get port() {
- return this.#port;
+ static get port() {
+ return Server.#port;
}
/** Get the `hostname` of the `Server` */
- get hostname() {
- return this.#hostname;
+ static get hostname() {
+ return Server.#hostname;
}
/** Called before a connection to a client has been responded to */