From baf4c00fee99eff8dae8d790bd8c0c4349c19318 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 26 Aug 2023 12:01:46 -0500 Subject: [PATCH] instance: add urls.nostr_relay and pubkey properties to instance --- src/controllers/api/instance.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/controllers/api/instance.ts b/src/controllers/api/instance.ts index d0235f5..0b5706a 100644 --- a/src/controllers/api/instance.ts +++ b/src/controllers/api/instance.ts @@ -5,6 +5,9 @@ import type { Context } from '@/deps.ts'; function instanceController(c: Context) { const { host, protocol } = Conf.url; + /** Protocol to use for WebSocket URLs, depending on the protocol of the `LOCAL_DOMAIN`. */ + const wsProtocol = protocol === 'http:' ? 'ws:' : 'wss:'; + return c.json({ uri: host, title: 'Ditto', @@ -35,10 +38,15 @@ function instanceController(c: Context) { user_count: 0, }, urls: { - streaming_api: `${protocol === 'http:' ? 'ws:' : 'wss:'}//${host}`, + /** Base URL for the streaming API, so it can be hosted on another domain. Clients will add `/api/v1/streaming` to it. */ + streaming_api: `${wsProtocol}//${host}`, + /** Full URL to the Nostr relay. */ + nostr_relay: `${wsProtocol}//${host}/relay`, }, version: '0.0.0 (compatible; Ditto 0.0.1)', email: Conf.adminEmail, + /** Ditto admin pubkey, so clients can query and validate Nostr events from the server. */ + pubkey: Conf.pubkey, rules: [], }); }