forked from Txio-labs/txio-telegram-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ts
More file actions
34 lines (31 loc) · 1.26 KB
/
Copy pathconfig.ts
File metadata and controls
34 lines (31 loc) · 1.26 KB
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
26
27
28
29
30
31
32
33
34
import "dotenv/config";
function required(name: string): string {
const value = process.env[name];
if (!value) {
throw new Error(`Missing required environment variable: ${name}`);
}
return value;
}
function optionalInt(name: string): number | undefined {
const value = process.env[name];
return value ? Number(value) : undefined;
}
export const config = {
port: Number(process.env.PORT ?? 3000),
telegramBotToken: required("TELEGRAM_BOT_TOKEN"),
telegramChatId: required("TELEGRAM_CHAT_ID"),
githubWebhookSecret: required("GITHUB_WEBHOOK_SECRET"),
githubWebhookPath: process.env.GITHUB_WEBHOOK_PATH ?? "/webhooks/github",
// Public base URL this service is reachable at, used to register the Telegram webhook.
publicUrl: required("PUBLIC_URL"),
telegramWebhookPath: process.env.TELEGRAM_WEBHOOK_PATH ?? "/telegram/webhook",
// Forum topic (message_thread_id) each event type posts into. Unset = group's General topic.
topicThreads: {
issues: optionalInt("TOPIC_THREAD_ISSUES"),
ci: optionalInt("TOPIC_THREAD_CI"),
deploys: optionalInt("TOPIC_THREAD_DEPLOYS"),
},
// If set, pull request notifications go to this chat (e.g. your personal DM)
// instead of the group.
pullRequestChatId: process.env.PULL_REQUEST_CHAT_ID || undefined,
};