From 3880f1e013d42b51aad5716c2e7873cd53c3ba6e Mon Sep 17 00:00:00 2001 From: Siddharth Singh Date: Wed, 24 Apr 2024 21:32:02 +0530 Subject: [PATCH 1/3] allow configuring the local port ditto listens on --- src/config.ts | 5 +++++ src/server.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index dfcd2f7..29f1d58 100644 --- a/src/config.ts +++ b/src/config.ts @@ -39,6 +39,11 @@ class Conf { ['sign', 'verify'], ); } + + static get localPort() { + return parseInt(Deno.env.get('DITTO_LISTEN_ON') || '8000'); + } + static get relay(): `wss://${string}` | `ws://${string}` { const { protocol, host } = Conf.url; return `${protocol === 'https:' ? 'wss:' : 'ws:'}//${host}/relay`; diff --git a/src/server.ts b/src/server.ts index f433cde..6333a73 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,5 +1,6 @@ import '@/precheck.ts'; import '@/sentry.ts'; import app from '@/app.ts'; +import { Conf } from '@/config.ts'; -Deno.serve(app.fetch); +Deno.serve({ port: Conf.localPort }, app.fetch); From 58b034e169e08ff18fce1638dbf129bd3716b8da Mon Sep 17 00:00:00 2001 From: Siddharth Singh Date: Wed, 24 Apr 2024 21:38:05 +0530 Subject: [PATCH 2/3] rename DITTO_LISTEN_ON and localPort() to PORT and port() --- src/config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config.ts b/src/config.ts index 29f1d58..c4d6a9b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -40,8 +40,8 @@ class Conf { ); } - static get localPort() { - return parseInt(Deno.env.get('DITTO_LISTEN_ON') || '8000'); + static get port() { + return parseInt(Deno.env.get('PORT') || '8000'); } static get relay(): `wss://${string}` | `ws://${string}` { From 953295c534392b940a1a802ef9715463b50089ff Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 24 Apr 2024 16:26:56 +0000 Subject: [PATCH 3/3] server.ts: Conf.localPort -> Conf.port --- src/server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server.ts b/src/server.ts index 6333a73..68af681 100644 --- a/src/server.ts +++ b/src/server.ts @@ -3,4 +3,4 @@ import '@/sentry.ts'; import app from '@/app.ts'; import { Conf } from '@/config.ts'; -Deno.serve({ port: Conf.localPort }, app.fetch); +Deno.serve({ port: Conf.port }, app.fetch);