-
Notifications
You must be signed in to change notification settings - Fork 4
/
config.ts
25 lines (21 loc) · 846 Bytes
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { parseBool } from "./util.ts";
function get(key: string): string;
function get<T>(key: string, def: T): string | T;
function get<T>(key: string, def?: T): string | T {
const value = Deno.env.get(key);
if (value !== undefined) return value;
else if (def !== undefined) return def;
throw new Error(`Missing environment variable '${key}'.`);
}
export default {
debug: parseBool(get("DEBUG", "0")),
hostname: get("HOSTNAME", "127.0.0.1"),
port: parseInt(get("PORT", "8080")),
signKey: get("SIGN_KEY", null),
maxWebhookRetries: parseInt(get("MAX_RETRIES", "3")),
maxWebhookRetryMs: parseInt(get("MAX_RETRY_MS", "30000")),
mainRedirect: get("MAIN_REDIRECT", null),
KV_PATH: get("KV_PATH", null) ?? undefined,
// set by deno deploy
deployId: get("DENO_DEPLOYMENT_ID", "<unknown>"),
};