diff options
| author | Fuwn <[email protected]> | 2022-05-17 07:44:28 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-05-17 07:44:28 +0000 |
| commit | ffb5363536664ac9b9c6f96beabb653437ce1137 (patch) | |
| tree | 65026a8d84718c641327d0d3b626bced85550f1a | |
| parent | chore(deno.json): update compileroptions (diff) | |
| download | laurali-ffb5363536664ac9b9c6f96beabb653437ce1137.tar.xz laurali-ffb5363536664ac9b9c6f96beabb653437ce1137.zip | |
feat(server): un-static #hostname and #port
| -rw-r--r-- | examples/my_cool_server.ts | 2 | ||||
| -rw-r--r-- | laurali/server.ts | 16 |
2 files changed, 9 insertions, 9 deletions
diff --git a/examples/my_cool_server.ts b/examples/my_cool_server.ts index 793e01f..3cf3b6d 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 ${MyCoolServer.hostname}:${MyCoolServer.port}.`, + `Listening on ${this.hostname}:${this.port}.`, ); } } diff --git a/laurali/server.ts b/laurali/server.ts index b2a2446..bd2ff87 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` */ - static #port: number; + #port: number; /** The hostname of the `Server` */ - static #hostname: string; + #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"; - Server.#port = port; - Server.#hostname = hostname; + this.#port = port; + this.#hostname = hostname; this.#listener = Deno.listenTls({ port, @@ -78,13 +78,13 @@ export abstract class Server { } /** Get the `port` of the `Server` */ - static get port() { - return Server.#port; + get port() { + return this.#port; } /** Get the `hostname` of the `Server` */ - static get hostname() { - return Server.#hostname; + get hostname() { + return this.#hostname; } /** Called before a connection to a client has been responded to */ |