Gateway: watch API, pairing, notifications, APNs sender, CLI, tests
This commit is contained in:
1 parent
972f6e4be5
commit
6ca098b701
12 files changed
+1297
-1
No files matched your search
@@ -0,0 +1,26 @@
|
||||
// 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" }
|
||||
: null,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user