This repository has no description
0

Configure Feed

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

core / web / src / lib / server / config.ts
1.1 kB 37 lines
1import { env } from "$env/dynamic/private"; 2 3const cleanUrl = (value: string | undefined, fallback: string) => { 4 const raw = value?.trim() || fallback; 5 return raw.replace(/\/+$/, ""); 6}; 7 8export type WebConfig = { 9 bobbinUrl: string; 10 apiUrl: string; 11 knotResolverUrl: string; 12 camoUrl: string; 13}; 14 15export type PublicWebConfig = Pick< 16 WebConfig, 17 "bobbinUrl" | "apiUrl" | "knotResolverUrl" | "camoUrl" 18>; 19 20type WebConfigEnv = { 21 BOBBIN_URL?: string; 22 TANGLED_API_URL?: string; 23 API_URL?: string; 24 KNOT_RESOLVER_URL?: string; 25 CAMO_URL?: string; 26}; 27 28export const resolveConfig = (values: WebConfigEnv): WebConfig => ({ 29 bobbinUrl: cleanUrl(values.BOBBIN_URL, "http://127.0.0.1:8090"), 30 apiUrl: cleanUrl(values.TANGLED_API_URL ?? values.API_URL, "http://127.0.0.1:8080"), 31 knotResolverUrl: cleanUrl(values.KNOT_RESOLVER_URL, "https://knot1.tangled.sh"), 32 camoUrl: cleanUrl(values.CAMO_URL, "https://camo.tangled.sh") 33}); 34 35export const getConfig = (): WebConfig => resolveConfig(env as WebConfigEnv); 36 37export const getPublicConfig = (): PublicWebConfig => getConfig();