Openstatus www.openstatus.dev

chore: throw error if missing env (#1630)

* chore: throw error if missing env

* fix: test scripts

authored by

Maximilian Kaske and committed by
GitHub
be8b3dce 8ae83f76

+21 -3
+3
.env.docker.example
··· 127 127 # Slack webhook (optional) 128 128 SLACK_SUPPORT_WEBHOOK_URL= 129 129 130 + # Telegram Bot (optional) 131 + TELEGRAM_BOT_TOKEN= 132 + 130 133 # SERVICE CONFIGURATION 131 134 # ============================================================================ 132 135 NODE_ENV=production
+1
apps/workflows/.env.test
··· 13 13 SCREENSHOT_SERVICE_URL=http://your.endpoint 14 14 NEXT_PUBLIC_OPENPANEL_CLIENT_ID=test 15 15 OPENPANEL_CLIENT_SECRET=test 16 + TELEGRAM_BOT_TOKEN=test
+3
packages/notifications/discord/package.json
··· 2 2 "name": "@openstatus/notification-discord", 3 3 "version": "1.0.0", 4 4 "main": "src/index.ts", 5 + "scripts": { 6 + "test": "bun test" 7 + }, 5 8 "dependencies": { 6 9 "@openstatus/db": "workspace:*", 7 10 "zod": "3.25.76"
+3
packages/notifications/ntfy/package.json
··· 2 2 "name": "@openstatus/notification-ntfy", 3 3 "version": "1.0.0", 4 4 "main": "src/index.ts", 5 + "scripts": { 6 + "test": "bun test" 7 + }, 5 8 "dependencies": { 6 9 "@openstatus/db": "workspace:*", 7 10 "zod": "3.25.76"
+3
packages/notifications/opsgenie/package.json
··· 2 2 "name": "@openstatus/notification-opsgenie", 3 3 "version": "0.0.0", 4 4 "main": "src/index.ts", 5 + "scripts": { 6 + "test": "bun test" 7 + }, 5 8 "dependencies": { 6 9 "@openstatus/db": "workspace:*", 7 10 "@t3-oss/env-core": "0.7.1",
+1 -1
packages/notifications/pagerduty/package.json
··· 1 1 { 2 2 "name": "@openstatus/notification-pagerduty", 3 3 "version": "0.0.0", 4 + "main": "src/index.ts", 4 5 "scripts": { 5 6 "test": "bun test" 6 7 }, 7 - "main": "src/index.ts", 8 8 "dependencies": { 9 9 "@openstatus/db": "workspace:*", 10 10 "@t3-oss/env-core": "0.7.1",
+3
packages/notifications/telegram/package.json
··· 2 2 "name": "@openstatus/notification-telegram", 3 3 "version": "1.0.0", 4 4 "main": "src/index.ts", 5 + "scripts": { 6 + "test": "bun test" 7 + }, 5 8 "dependencies": { 6 9 "@openstatus/db": "workspace:*", 7 10 "zod": "3.25.76"
+1 -1
packages/notifications/telegram/src/index.test.ts
··· 185 185 expect(fetchMock).toHaveBeenCalledTimes(1); 186 186 }); 187 187 188 - test("sendMessage returns undefined when TELEGRAM_BOT_TOKEN is not set", async () => { 188 + test("fetch not called when TELEGRAM_BOT_TOKEN is not set", async () => { 189 189 process.env.TELEGRAM_BOT_TOKEN = undefined; 190 190 191 191 const monitor = createMockMonitor();
+3 -1
packages/notifications/telegram/src/index.ts
··· 131 131 chatId: string; 132 132 message: string; 133 133 }) { 134 - if (!process.env.TELEGRAM_BOT_TOKEN) return; 134 + if (!process.env.TELEGRAM_BOT_TOKEN) { 135 + throw new Error("TELEGRAM_BOT_TOKEN is not set"); 136 + } 135 137 return fetch( 136 138 `https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage?chat_id=${chatId}&text=${message}`, 137 139 );