fix(server): require DATABASE_URL and JWT_SECRET, warn on missing Ste… - #223
Merged
Conversation
…llar vars REQUIRED_ENV_VARS in server/src/index.ts was left empty, so the server started successfully even without DATABASE_URL or JWT_SECRET, failing only later with confusing runtime errors on first DB query or JWT sign. Now validates both as required and exits(1) with a clear [startup] log if either is missing. STELLAR_NETWORK, HORIZON_URL, and SOROBAN_RPC_URL are validated as optional (warning only) since they're not needed for auth-only flows.
|
@cokehill Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Problem
REQUIRED_ENV_VARSinserver/src/index.tswas explicitly leftempty. A misconfigured production deployment would start, accept
requests, and only throw runtime errors on the first database query
or JWT sign — instead of failing fast at startup with a clear message.
Fix
DATABASE_URLandJWT_SECRETadded toREQUIRED_ENV_VARS; servernow exits(1) with
[startup] Missing required environment variables: ...if either is absent.
STELLAR_NETWORK,HORIZON_URL, andSOROBAN_RPC_URLadded as aseparate optional list — logged as a warning (not fatal) since
they're not required for auth-only flows.
server/.env.examplehas non-empty placeholder values forboth required variables, so
cp .env.example .envproduces astartable dev config.
when
DATABASE_URLis unset.Testing
Closes #130
Closes #131
Closes #137
Closes #127