service status on atproto
at main 799 B view raw
1import { isDid, type AtprotoDid } from "@atcute/lexicons/syntax"; 2import { env } from "process"; 3 4interface Config { 5 repoDid: AtprotoDid; 6 appPass: string; 7 hostName?: string; 8 hostDescription?: string; 9} 10 11const required = (value: unknown) => typeof value !== "undefined"; 12 13const getConfig = (prefix: string): Config => { 14 const get = <Value>( 15 name: string, 16 check: (value: unknown) => boolean = () => true, 17 ): Value => { 18 const value = env[`${prefix}${name}`]; 19 if (check(value)) return value as Value; 20 throw `config key ${name} is invalid`; 21 }; 22 return { 23 repoDid: get("REPO_DID", isDid), 24 appPass: get("APP_PASSWORD", required), 25 hostName: get("HOST_NAME"), 26 hostDescription: get("HOST_DESCRIPTION"), 27 }; 28}; 29 30export const config = getConfig("BAROMETER_");