25 lines
835 B
TypeScript
Raw Normal View History

2022-09-03 20:14:57 +02:00
import { parseBool } from "./util.ts";
2022-09-03 01:14:28 +02:00
2022-09-04 14:35:05 +02:00
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;
2022-09-02 22:24:33 +02:00
throw new Error(`Missing environment variable '${key}'.`);
}
export default {
2022-09-03 20:14:57 +02:00
debug: parseBool(get("DEBUG", "0")),
2022-09-02 22:24:33 +02:00
hostname: get("HOSTNAME", "127.0.0.1"),
port: parseInt(get("PORT", "8080")),
2022-09-04 14:39:03 +02:00
signKey: get("SIGN_KEY", null),
2022-09-03 18:03:51 +02:00
maxWebhookRetries: parseInt(get("MAX_RETRIES", "3")),
maxWebhookRetryMs: parseInt(get("MAX_RETRY_MS", "30000")),
2022-09-04 14:54:10 +02:00
mainRedirect: get("MAIN_REDIRECT", null),
redisUrl: get("REDIS_URL", null),
2022-09-04 15:34:19 +02:00
// set by deno deploy
deployId: get("DENO_DEPLOYMENT_ID", "<unknown>"),
2022-09-02 22:24:33 +02:00
};