Skip to content

Open-source status page, incident response and uptime monitoring

chore: throw error if missing env (#1630)

Maximilian Kaskebe8b3dce20e2
diff --git a/.env.docker.example b/.env.docker.example
index dcf15de06..1641f49ab 100644
--- a/.env.docker.example
+++ b/.env.docker.example
@@ -127,6 +127,9 @@ PAGERDUTY_APP_ID=
# Slack webhook (optional)
SLACK_SUPPORT_WEBHOOK_URL=
+# Telegram Bot (optional)
+TELEGRAM_BOT_TOKEN=
+
# SERVICE CONFIGURATION
# ============================================================================
NODE_ENV=production
diff --git a/apps/workflows/.env.test b/apps/workflows/.env.test
index 4e7111d5a..777efbe41 100644
--- a/apps/workflows/.env.test
+++ b/apps/workflows/.env.test
@@ -13,3 +13,4 @@ SQLD_HTTP_AUTH=basic:token
SCREENSHOT_SERVICE_URL=http://your.endpoint
NEXT_PUBLIC_OPENPANEL_CLIENT_ID=test
OPENPANEL_CLIENT_SECRET=test
+TELEGRAM_BOT_TOKEN=test
\ No newline at end of file
diff --git a/packages/notifications/discord/package.json b/packages/notifications/discord/package.json
index 9a7d58c0a..aa21a4e21 100644
--- a/packages/notifications/discord/package.json
+++ b/packages/notifications/discord/package.json
@@ -2,6 +2,9 @@
"name": "@openstatus/notification-discord",
"version": "1.0.0",
"main": "src/index.ts",
+ "scripts": {
+ "test": "bun test"
+ },
"dependencies": {
"@openstatus/db": "workspace:*",
"zod": "3.25.76"
diff --git a/packages/notifications/ntfy/package.json b/packages/notifications/ntfy/package.json
index c526c8005..722f7fdcd 100644
--- a/packages/notifications/ntfy/package.json
+++ b/packages/notifications/ntfy/package.json
@@ -2,6 +2,9 @@
"name": "@openstatus/notification-ntfy",
"version": "1.0.0",
"main": "src/index.ts",
+ "scripts": {
+ "test": "bun test"
+ },
"dependencies": {
"@openstatus/db": "workspace:*",
"zod": "3.25.76"
diff --git a/packages/notifications/opsgenie/package.json b/packages/notifications/opsgenie/package.json
index c1a8cd6ab..6b54939bc 100644
--- a/packages/notifications/opsgenie/package.json
+++ b/packages/notifications/opsgenie/package.json
@@ -2,6 +2,9 @@
"name": "@openstatus/notification-opsgenie",
"version": "0.0.0",
"main": "src/index.ts",
+ "scripts": {
+ "test": "bun test"
+ },
"dependencies": {
"@openstatus/db": "workspace:*",
"@t3-oss/env-core": "0.7.1",
diff --git a/packages/notifications/pagerduty/package.json b/packages/notifications/pagerduty/package.json
index 28a60eb6a..c26ffccd1 100644
--- a/packages/notifications/pagerduty/package.json
+++ b/packages/notifications/pagerduty/package.json
@@ -1,10 +1,10 @@
{
"name": "@openstatus/notification-pagerduty",
"version": "0.0.0",
+ "main": "src/index.ts",
"scripts": {
"test": "bun test"
},
- "main": "src/index.ts",
"dependencies": {
"@openstatus/db": "workspace:*",
"@t3-oss/env-core": "0.7.1",
diff --git a/packages/notifications/telegram/package.json b/packages/notifications/telegram/package.json
index 77d460f64..2a5644ada 100644
--- a/packages/notifications/telegram/package.json
+++ b/packages/notifications/telegram/package.json
@@ -2,6 +2,9 @@
"name": "@openstatus/notification-telegram",
"version": "1.0.0",
"main": "src/index.ts",
+ "scripts": {
+ "test": "bun test"
+ },
"dependencies": {
"@openstatus/db": "workspace:*",
"zod": "3.25.76"
diff --git a/packages/notifications/telegram/src/index.test.ts b/packages/notifications/telegram/src/index.test.ts
index c479e97c9..86fd2bb9f 100644
--- a/packages/notifications/telegram/src/index.test.ts
+++ b/packages/notifications/telegram/src/index.test.ts
@@ -185,7 +185,7 @@ describe("Telegram Notifications", () => {
expect(fetchMock).toHaveBeenCalledTimes(1);
});
- test("sendMessage returns undefined when TELEGRAM_BOT_TOKEN is not set", async () => {
+ test("fetch not called when TELEGRAM_BOT_TOKEN is not set", async () => {
process.env.TELEGRAM_BOT_TOKEN = undefined;
const monitor = createMockMonitor();
diff --git a/packages/notifications/telegram/src/index.ts b/packages/notifications/telegram/src/index.ts
index add4a4d7b..bfb1e0422 100644
--- a/packages/notifications/telegram/src/index.ts
+++ b/packages/notifications/telegram/src/index.ts
@@ -131,7 +131,9 @@ export async function sendMessage({
chatId: string;
message: string;
}) {
- if (!process.env.TELEGRAM_BOT_TOKEN) return;
+ if (!process.env.TELEGRAM_BOT_TOKEN) {
+ throw new Error("TELEGRAM_BOT_TOKEN is not set");
+ }
return fetch(
`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage?chat_id=${chatId}&text=${message}`,
);