github-webhook-filter/lib/config.ts

19 lines
556 B
TypeScript
Raw Normal View History

2022-09-03 18:14:57 +00:00
import { parseBool } from "./util.ts";
2022-09-02 23:14:28 +00:00
2022-09-02 20:24:33 +00:00
function get(key: string, def?: string): string {
const value = Deno.env.get(key) ?? def;
if (value !== undefined) {
return value;
}
throw new Error(`Missing environment variable '${key}'.`);
}
export default {
2022-09-03 18:14:57 +00:00
debug: parseBool(get("DEBUG", "0")),
2022-09-02 20:24:33 +00:00
hostname: get("HOSTNAME", "127.0.0.1"),
port: parseInt(get("PORT", "8080")),
signKey: get("SIGN_KEY"),
2022-09-03 16:03:51 +00:00
maxWebhookRetries: parseInt(get("MAX_RETRIES", "3")),
maxWebhookRetryMs: parseInt(get("MAX_RETRY_MS", "30000")),
2022-09-02 20:24:33 +00:00
};