refactor: consolidate CCXRAY_HOME resolution into server/paths.js#52
Merged
Conversation
hub.js, settings.js, ratelimit-log.js, and auth.js each inlined the same 'process.env.CCXRAY_HOME || path.join(os.homedir(), ".ccxray")' expression. Replace all four with resolveCcxrayHome() from server/paths.js (introduced in #50), and drop the now-unused 'os' import in each. auth.js keeps the call inside getHubDir() so it still reads the env per call. Pure de-duplication — identical behavior, no precedence change. The CCXRAY_HOME contract is now enforced in one place, so it can't drift the way config.LOGS_DIR did in #31. Closes #51
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.
Closes #51. Follow-up to #50.
#50 introduced
server/paths.jsas the single source of truth for ccxray's on-disk locations, wiringconfig.js+storage/index.jsto it. Four other modules still inlined the sameprocess.env.CCXRAY_HOME || path.join(os.homedir(), '.ccxray')expression.Change
Replace the inline resolution with
resolveCcxrayHome()and drop the now-unusedosimport in each:server/hub.js—HUB_DIRserver/settings.js—SETTINGS_DIRserver/ratelimit-log.js—CCXRAY_HOMEserver/auth.js—getHubDir()(call kept inside the function, preserving per-call env read)Plus: refreshed the now-accurate
paths.jsheader comment.Guarantees
resolveCcxrayHome()returns exactlyenv.CCXRAY_HOME || path.join(os.homedir(), '.ccxray'), identical to each removed expression. No precedence or behavior change.CCXRAY_HOMEcontract can no longer drift the wayconfig.LOGS_DIRdid in config.LOGS_DIR does not honor CCXRAY_HOME (banner + legacy migration use wrong path) #31.Verification
node -con all 5 touched files; confirmedosfully removed (0 refs) in the 4 consumers.Reviewed
Codex (gpt-5.5, xhigh) — no blockers; the one nit (stale
paths.jscomment) is included in this PR.Out of scope
S3 banner / legacy-migration regression tests (the other #51 checklist items) — left for a separate change to keep this PR a clean mechanical refactor.