Skip to content

Add scheduled alerts worker and shared telegram package - #18

Merged
valuecodes merged 1 commit into
mainfrom
feat/alerts-worker
Jul 12, 2026
Merged

Add scheduled alerts worker and shared telegram package#18
valuecodes merged 1 commit into
mainfrom
feat/alerts-worker

Conversation

@valuecodes

Copy link
Copy Markdown
Owner

What

  • Adds a home for recurring scheduled notifications (e.g. a daily "S&P 500 % below ATH"). Stage 1 ships a single healthcheck alert, built around an extensible array of alerts.
  • New non-public cron Worker apps/alerts (workers_dev: false); the scheduled handler dispatches per-alert by matching event.cron, so alerts can mix cadences.
  • Extracts Telegram sending into a shared @repo/telegram package; apps/operator now consumes it instead of its local service.
  • Splits package exports into . (impl) vs ./types for telegram/logger/http-client, and adds a repo-wide no-barrel-re-export ESLint rule in the base config.

How to test

pnpm typecheck
pnpm lint
pnpm test
pnpm format:check
Recommended: pnpm --filter @repo/alerts dev
Recommended: curl "http://localhost:8787/__scheduled?cron=0+8+*+*+*"

Security review

  • Secrets / env vars: alerts worker reads TELEGRAM_BOT_TOKEN + ALLOWED_CHAT_ID (zod-validated); set in prod via wrangler secret put, never committed.
  • Network / API calls: alerts worker sends outbound to the Telegram Bot API via @repo/telegram; reuses the operator's bot and registers no inbound webhook.

Copilot AI review requested due to automatic review settings July 12, 2026 06:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new scheduled “alerts” Cloudflare Worker and extracts Telegram sending into a shared @repo/telegram package, while tightening module boundaries by exposing types via explicit package.json subpath exports and enforcing a repo-wide “no barrel re-exports” ESLint rule.

Changes:

  • Introduce apps/alerts (scheduled-only Worker) with an extensible alerts registry and a stage-1 daily healthcheck alert.
  • Create packages/telegram and migrate apps/operator to consume it (plus ./types subpath usage).
  • Add explicit ./types exports for logger/http-client and enforce no re-export “barrels” via ESLint.

Reviewed changes

Copilot reviewed 32 out of 34 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tooling/eslint/base.ts Adds repo-wide restriction against re-export “barrels”.
pnpm-lock.yaml Registers new apps/alerts and packages/telegram workspaces and deps.
packages/telegram/vitest.config.ts Adds Vitest config for the new telegram package.
packages/telegram/tsconfig.json Adds TS config for the new telegram package.
packages/telegram/src/types.ts Defines Zod schemas + exported types for Telegram API payloads.
packages/telegram/src/telegram.ts Implements TelegramService on top of @repo/http-client.
packages/telegram/src/telegram.test.ts Adds unit tests for TelegramService methods and error handling.
packages/telegram/package.json Declares @repo/telegram exports, including ./types.
packages/telegram/eslint.config.ts Hooks the shared base ESLint config for the new package.
packages/logger/src/logger.ts Removes type re-exports to comply with no-barrel policy.
packages/logger/package.json Adds ./types export subpath.
packages/http-client/src/http-client.ts Removes type re-exports to comply with no-barrel policy.
packages/http-client/package.json Adds ./types export subpath.
apps/operator/src/types/telegram.ts Removes Telegram send/edit param schemas/types now provided by @repo/telegram.
apps/operator/src/scheduled.ts Switches scheduled handler to use shared TelegramService.
apps/operator/src/modules/telegram/ui.ts Switches InlineKeyboardMarkup type import to @repo/telegram/types.
apps/operator/src/modules/telegram/conversation-runner.ts Updates TelegramService type import to shared package.
apps/operator/src/modules/telegram/controller.ts Updates controller to use shared TelegramService.
apps/operator/src/middleware/tests/logger.test.ts Updates LogEntry type import to @repo/logger/types.
apps/operator/package.json Adds dependency on @repo/telegram.
apps/alerts/wrangler.jsonc Adds Worker config (scheduled trigger, no dev deployment, observability).
apps/alerts/tsconfig.json Adds TS config for the alerts worker.
apps/alerts/src/types/env.ts Adds Zod validation for alerts worker bindings.
apps/alerts/src/scheduled.ts Implements scheduled dispatch to per-alert runners and Telegram sending.
apps/alerts/src/scheduled.test.ts Adds tests for cron matching and Telegram sending behavior.
apps/alerts/src/index.ts Wires the scheduled handler into the Worker default export.
apps/alerts/src/alerts/types.ts Defines the Alert contract and context passed to alerts.
apps/alerts/src/alerts/index.ts Registers the alert list (currently healthcheck).
apps/alerts/src/alerts/healthcheck.ts Implements the stage-1 daily heartbeat alert.
apps/alerts/README.md Documents behavior, local dev workflow, and secret setup.
apps/alerts/package.json Adds new workspace package config and scripts.
apps/alerts/eslint.config.ts Hooks the shared base ESLint config for the alerts app.
AGENTS.md Updates repo snapshot to include the new app/package workspaces.
.github/workflows/main.yml Adds deploy step for @repo/alerts to Cloudflare Workers.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +3 to +6
const envSchema = z.object({
TELEGRAM_BOT_TOKEN: z.string().min(1),
ALLOWED_CHAT_ID: z.string().min(1),
});
@valuecodes
valuecodes merged commit 615e083 into main Jul 12, 2026
8 checks passed
@valuecodes
valuecodes deleted the feat/alerts-worker branch July 12, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants