Auto-indexing service and GraphQL API for AT Protocol Records
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(config): add PLC_DIRECTORY_URL env var override for bootstrap

+16 -47
+9 -20
server/src/database/repositories/config.gleam
··· 1 - import gleam/dict.{type Dict} 1 + import envoy 2 2 import gleam/dynamic/decode 3 3 import gleam/list 4 4 import gleam/result ··· 45 45 -1, 46 46 )) 47 47 Error(err) -> Error(err) 48 - } 49 - } 50 - 51 - /// Get all config values as a dictionary 52 - pub fn get_all(conn: sqlight.Connection) -> Dict(String, String) { 53 - let sql = "SELECT key, value FROM config" 54 - 55 - let decoder = { 56 - use key <- decode.field(0, decode.string) 57 - use value <- decode.field(1, decode.string) 58 - decode.success(#(key, value)) 59 - } 60 - 61 - case sqlight.query(sql, on: conn, with: [], expecting: decoder) { 62 - Ok(rows) -> dict.from_list(rows) 63 - Error(_) -> dict.new() 64 48 } 65 49 } 66 50 ··· 207 191 } 208 192 } 209 193 210 - /// Get PLC directory URL from config, with default fallback 194 + /// Get PLC directory URL with precedence: env var → database → default 211 195 pub fn get_plc_directory_url(conn: sqlight.Connection) -> String { 212 - case get(conn, "plc_directory_url") { 196 + case envoy.get("PLC_DIRECTORY_URL") { 213 197 Ok(url) -> url 214 - Error(_) -> default_plc_directory_url 198 + Error(_) -> { 199 + case get(conn, "plc_directory_url") { 200 + Ok(url) -> url 201 + Error(_) -> default_plc_directory_url 202 + } 203 + } 215 204 } 216 205 } 217 206
+7 -27
server/src/lib/mcp/tools/capabilities.gleam
··· 1 1 import database/repositories/config 2 2 import database/repositories/lexicons 3 3 import database/repositories/records 4 - import gleam/dict 5 4 import gleam/json 6 - import gleam/list 7 5 import gleam/option.{None, Some} 8 6 import gleam/result 9 - import gleam/string 10 7 import sqlight 11 8 12 9 /// Get server capabilities ··· 21 18 records.get_count(db) 22 19 |> result.unwrap(0) 23 20 24 - // Get all config values in a single query 25 - let cfg = config.get_all(db) 26 - 27 - let relay_url = 28 - dict.get(cfg, "relay_url") 29 - |> result.unwrap(config.default_relay_url) 30 - let jetstream_url = 31 - dict.get(cfg, "jetstream_url") 32 - |> result.unwrap(config.default_jetstream_url) 33 - let plc_directory_url = 34 - dict.get(cfg, "plc_directory_url") 35 - |> result.unwrap(config.default_plc_directory_url) 36 - let oauth_supported_scopes = 37 - dict.get(cfg, "oauth_supported_scopes") 38 - |> result.unwrap(config.default_oauth_supported_scopes) 39 - let admin_dids = case dict.get(cfg, "admin_dids") { 40 - Ok(value) -> 41 - value 42 - |> string.split(",") 43 - |> list.map(string.trim) 44 - |> list.filter(fn(did) { !string.is_empty(did) }) 45 - Error(_) -> [] 46 - } 47 - let domain_authority = case dict.get(cfg, "domain_authority") { 21 + // Get config values using individual getters (handles env var precedence) 22 + let relay_url = config.get_relay_url(db) 23 + let jetstream_url = config.get_jetstream_url(db) 24 + let plc_directory_url = config.get_plc_directory_url(db) 25 + let oauth_supported_scopes = config.get_oauth_supported_scopes(db) 26 + let admin_dids = config.get_admin_dids(db) 27 + let domain_authority = case config.get(db, "domain_authority") { 48 28 Ok(value) -> Some(value) 49 29 Error(_) -> None 50 30 }