Skip to content

Validate RESEND_API_KEY and structured rate-limit logs - #483

Merged
neuromechanist merged 3 commits into
devfrom
feature/issue-478-broadcast-precond
May 14, 2026
Merged

neuromechanist merged 3 commits into
devfrom
feature/issue-478-broadcast-precond

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Closes #478

Part 1: rate-limit cache observability

backend/src/middleware/rateLimit.ts — the catch block now emits a structured log with { route, keyKind, error } instead of a bare string, making Workers tail-log filtering actionable. A TODO marks where a Sentry capture belongs once a DSN is wired.

Part 2: RESEND_API_KEY precondition

backend/src/services/broadcast.ts — sendBroadcast now short-circuits at the top if the key is empty or whitespace, returning { broadcast_id: -1, error: "email_service_unconfigured" }. The /admin/notify route handler maps that to HTTP 500 so admins see the real problem rather than a 200 with every recipient marked failed.

Tests

test/broadcast.test.ts — 3 new tests (24 total, all pass):

  • missing key (empty string) returns structured error, no Resend call made
  • whitespace-only key returns structured error, no Resend call made
  • valid key proceeds to call Resend and returns broadcast_id

Augment the catch block with route, keyKind, and error message
so Workers tail logs surface cache outages. Adds TODO for Sentry.
Return email_service_unconfigured (broadcast_id: -1) instead of
silently recording all recipients as failures. Route handler maps
this to HTTP 500 so admins see the real cause. Tests cover empty,
whitespace, and valid-key paths.
@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR483

Version: 0.8.14-PR483.9485674
Commit: 9485674


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit c25b313 into dev May 14, 2026
2 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-478-broadcast-precond branch May 14, 2026 12:34

This branch was previously deployed

1 inactive deployment
npm — a1636604 Deployed May 14, 2026 by neuromechanist via publish #859
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.

1 participant