Files
wristcode/gateway/src/config.ts
T
gib 69858d4719
Gateway / check (push) Successful in 30s
Gateway / image (push) Successful in 46s
Gateway: APNs topic is the watch app's bundle ID
2026-11-01 10:09:26 -05:00

27 lines
879 B
TypeScript

// Settings from the environment. Only the database path is needed to run. Without the APNs
// settings the gateway still serves the watch, it just logs pushes instead of sending them.
import { readFileSync } from "node:fs";
import type { ApnsConfig } from "./apns.ts";
export interface Config {
port: number;
dbPath: string;
apns: ApnsConfig | null;
}
export function loadConfig(env = process.env): Config {
const keyId = env.APNS_KEY_ID;
const teamId = env.APNS_TEAM_ID;
const key = env.APNS_KEY ?? (env.APNS_KEY_PATH ? readFileSync(env.APNS_KEY_PATH, "utf8") : undefined);
return {
port: Number(env.PORT ?? 8080),
dbPath: env.WRISTCODE_DB ?? "data/wristcode.sqlite",
apns:
keyId && teamId && key
? { keyId, teamId, key: key.replace(/\\n/g, "\n"), topic: env.APNS_TOPIC ?? "org.gbrown.wristcode.watchkitapp" }
: null,
};
}