[READ ONLY MIRROR] Spark Social AppView Server github.com/sprksocial/server
atproto deno hono lexicon
1
fork

Configure Feed

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

at main 207 lines 5.3 kB view raw
1import * as dotenv from "dotenv"; 2import { envInt, envList, envStr } from "@atp/common/server"; 3 4dotenv.config({ quiet: true }); 5 6export interface ServerConfigValues { 7 version?: string; 8 debugMode?: boolean; 9 port?: number; 10 publicUrl?: string; 11 serverDid: string; 12 privateKey: string; 13 alternateAudienceDids: string[]; 14 modServiceDid: string; 15 adminPasswords: string[]; 16 indexedAtEpoch?: Date; 17 18 bigThreadUris: Set<string>; 19 bigThreadDepth?: number; 20 maxThreadDepth?: number; 21 maxThreadParents: number; 22 notificationsDelayMs: number; 23 24 videoCdn?: string; 25 mediaCdn?: string; 26 thumbCdn?: string; 27 28 dbUri?: string; 29 dbName?: string; 30 dbUser?: string; 31 dbPass?: string; 32 relayUrl?: string; 33 plcUrl?: string; 34 35 labelsFromIssuerDids: string[]; 36 37 // Push notifications (FCM handles both iOS and Android) 38 pushEnabled: boolean; 39 fcmServiceAccount?: string; 40} 41 42export class ServerConfig { 43 constructor(private cfg: ServerConfigValues) {} 44 45 static readEnv() { 46 const version = envStr("SPRK_VERSION"); 47 const debugMode = Deno.env.get("NODE_ENV") === "development" || 48 Deno.env.get("NODE_ENV") === "test"; 49 const port = envInt("SPRK_PORT") ?? 3000; 50 const publicUrl = envStr("SPRK_PUBLIC_URL") ?? undefined; 51 const serverDid = envStr("SPRK_SERVER_DID") ?? "did:example:test"; 52 const privateKey = envStr("SPRK_PRIVATE_KEY") ?? ""; 53 const alternateAudienceDids = envList("SPRK_ALTERNATE_AUDIENCE_DIDS") ?? []; 54 const modServiceDid = envStr("SPRK_MOD_SERVICE_DID") ?? "did:web:localhost"; 55 const adminPasswords = envList("SPRK_ADMIN_PASSWORDS") ?? ["admin-token"]; 56 57 const indexedAtEpochEnv = Deno.env.get("SPRK_INDEXED_AT_EPOCH"); 58 const indexedAtEpoch = indexedAtEpochEnv !== undefined 59 ? new Date(indexedAtEpochEnv) 60 : undefined; 61 62 const bigThreadUris = new Set(envList("SPRK_BIG_THREAD_URIS")); 63 const bigThreadDepth = envInt("SPRK_BIG_THREAD_DEPTH") ?? 10; 64 const maxThreadDepth = envInt("SPRK_MAX_THREAD_DEPTH") ?? 10; 65 const maxThreadParents = envInt("SPRK_MAX_THREAD_PARENTS") ?? 10; 66 const notificationsDelayMs = envInt("SPRK_NOTIFICATIONS_DELAY_MS") ?? 10; 67 68 const videoCdn = envStr("SPRK_VIDEO_CDN") ?? "https://video.sprk.so"; 69 const mediaCdn = envStr("SPRK_MEDIA_CDN") ?? "https://media.sprk.so"; 70 const thumbCdn = envStr("SPRK_THUMB_CDN") ?? "https://thumb.sprk.so"; 71 72 const dbUri = envStr("SPRK_DB_URI") ?? 73 "mongodb://mongo:mongo@localhost:27017/dev"; 74 const dbName = envStr("SPRK_DB_NAME") ?? "dev"; 75 const dbUser = envStr("SPRK_DB_USER") ?? "mongo"; 76 const dbPass = envStr("SPRK_DB_PASS") ?? "mongo"; 77 const relayUrl = envStr("SPRK_RELAY") ?? 78 "wss://relay1.us-east.bsky.network"; 79 const plcUrl = envStr("SPRK_PLC") ?? "https://plc.directory"; 80 81 const labelsFromIssuerDids = envList("SPRK_LABELS_FROM_ISSUER_DIDS") ?? []; 82 83 // Push notifications (FCM handles both iOS and Android) 84 const pushEnabled = Deno.env.get("SPRK_PUSH_ENABLED") === "true"; 85 const fcmServiceAccount = envStr("SPRK_FCM_SERVICE_ACCOUNT"); 86 87 return new ServerConfig({ 88 version, 89 debugMode, 90 port, 91 publicUrl, 92 serverDid, 93 privateKey, 94 alternateAudienceDids, 95 modServiceDid, 96 adminPasswords, 97 indexedAtEpoch, 98 bigThreadUris, 99 bigThreadDepth, 100 maxThreadDepth, 101 maxThreadParents, 102 notificationsDelayMs, 103 videoCdn, 104 mediaCdn, 105 thumbCdn, 106 dbUri, 107 dbName, 108 dbUser, 109 dbPass, 110 relayUrl, 111 plcUrl, 112 labelsFromIssuerDids, 113 pushEnabled, 114 fcmServiceAccount, 115 }); 116 } 117 118 get version() { 119 return this.cfg.version; 120 } 121 get debugMode() { 122 return this.cfg.debugMode; 123 } 124 get port() { 125 return this.cfg.port; 126 } 127 get publicUrl() { 128 return this.cfg.publicUrl; 129 } 130 get serverDid() { 131 return this.cfg.serverDid; 132 } 133 get privateKey() { 134 return this.cfg.privateKey; 135 } 136 get alternateAudienceDids() { 137 return this.cfg.alternateAudienceDids; 138 } 139 get modServiceDid() { 140 return this.cfg.modServiceDid; 141 } 142 get adminPasswords() { 143 return this.cfg.adminPasswords; 144 } 145 get indexedAtEpoch() { 146 return this.cfg.indexedAtEpoch; 147 } 148 149 // Threads 150 get bigThreadDepth() { 151 return this.cfg.bigThreadDepth; 152 } 153 get bigThreadUris() { 154 return this.cfg.bigThreadUris; 155 } 156 get maxThreadParents() { 157 return this.cfg.maxThreadParents; 158 } 159 get maxThreadDepth() { 160 return this.cfg.maxThreadDepth; 161 } 162 get notificationsDelayMs() { 163 return this.cfg.notificationsDelayMs; 164 } 165 166 // CDNs 167 get videoCdn() { 168 return this.cfg.videoCdn; 169 } 170 get mediaCdn() { 171 return this.cfg.mediaCdn; 172 } 173 get thumbCdn() { 174 return this.cfg.thumbCdn; 175 } 176 177 get dbUri() { 178 return this.cfg.dbUri; 179 } 180 get dbName() { 181 return this.cfg.dbName; 182 } 183 get dbUser() { 184 return this.cfg.dbUser; 185 } 186 get dbPass() { 187 return this.cfg.dbPass; 188 } 189 get relayUrl() { 190 return this.cfg.relayUrl; 191 } 192 get plcUrl() { 193 return this.cfg.plcUrl; 194 } 195 196 get labelsFromIssuerDids() { 197 return this.cfg.labelsFromIssuerDids; 198 } 199 200 // Push notifications (FCM handles both iOS and Android) 201 get pushEnabled() { 202 return this.cfg.pushEnabled; 203 } 204 get fcmServiceAccount() { 205 return this.cfg.fcmServiceAccount; 206 } 207}