Repository navigation
Read RESEND_API_KEY from component env - #164
Closed
convexwill wants to merge 1 commit into
Closed
convexwill wants to merge 1 commit into
convexwill wants to merge 1 commit into
Conversation
The component declares an optional RESEND_API_KEY env var and prefers it over the key forwarded by the client. The client's apiKey option is deprecated but keeps working as a fallback, with a warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Superseded by #165 (same commit, branch renamed to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of API-223: move first-party component credentials to component env vars, following expo-push-notifications#89. Resend goes first so we can get feedback on the pattern before Twilio, R2, Polar, LaunchDarkly and WorkOS.
What changes
The component declares an optional
RESEND_API_KEYenv var. Apps bind it inconvex/convex.config.ts:callResendAPIWithBatchresolves the key in this order:RESEND_API_KEYenv var.apiKeyoption, or the app'sprocess.env.RESEND_API_KEY). The component uses it and logs a deprecation warning.sendEmailfails right away withRESEND_API_KEY is not set. This replaces the client-side "API key is not set" check, since the client can no longer tell whether the component has a key.Compatibility
Nothing breaks on upgrade:
app.use(resend)withoutenvstill type-checks and deploys. convex 1.43.0 madeenvoptional inapp.usewhen all of a component's env vars are optional, and the existing^1.43.0peer range covers that.ResendOptions.apiKeyis marked@deprecatedand still works as a fallback.apiKeyis now optional invOptionsand in thecallResendAPIWithBatchargs. ExistinglastOptionsrows and queued workpool jobs still validate.Until a later major version removes forwarding, the client still sends the key through
sendEmailargs andlastOptions. The component ignores that copy once its env var is set.Out of scope:
RESEND_WEBHOOK_SECRET(the app's HTTP action verifies webhooks) andbaseUrl(API-89 / #130).Testing
src/client/index.test.ts:apiKeyoptionsendEmailAuthorizationheader.npm test(37 passing),npm run lint,npm run typecheck,npm run build._generatedfiles were regenerated withconvex codegenandconvex dev --onceagainst a local deployment.app.use(resend)to check backward compatibility.🤖 Generated with Claude Code