feat: structured logging, JSDoc types, and WEBHOOK_SECRET guard

- Replace string-interpolated console.log/error with JSON.stringify
  for searchable/filterable CF Workers dashboard logs
- Add shared JSDoc typedefs (Subscriber, QueueMessage, ChatTarget)
  with @param/@returns annotations on key functions
- Guard against undefined WEBHOOK_SECRET env var (auth bypass on
  misconfigured deploy)
- Add 3 declined features to feature-decisions.md (fan-out decoupling,
  idempotency keys, /ping)
This commit is contained in:
2026-04-09 11:30:00 +07:00
parent 39afb0fd68
commit 7949da3734
7 changed files with 104 additions and 31 deletions

21
src/types.js Normal file
View File

@@ -0,0 +1,21 @@
/**
* Shared JSDoc type definitions for the project.
* Import via: @import { Subscriber, QueueMessage, ChatTarget } from "./types.js"
*/
/**
* Subscriber preferences stored in KV value and metadata
* @typedef {{ types: string[], components: string[] }} Subscriber
*/
/**
* Message body enqueued to CF Queue for fan-out delivery
* @typedef {{ chatId: number, threadId: ?number, html: string }} QueueMessage
*/
/**
* Chat target extracted from Telegram update
* @typedef {{ chatId: number, threadId: ?number }} ChatTarget
*/
export {};