Harden Redis/Stellar/config handling (#220, #221, #222, #225) - #360
Merged
meshackyaro merged 11 commits intoAug 31, 2026
Merged
Conversation
REDIS_URL being unset used to throw at construction; a bad URL or an unreachable server produced an unhandled 'error' event that could crash the process. Extract createRedisClient() as an exported factory, return null (with a warning) when REDIS_URL is absent, attach error/connect/ reconnecting listeners, and kick off a connect() whose rejection is logged rather than thrown. Closes trustflow-protocol#220
getBalance() surfaced raw Horizon SDK errors, so a caller could not tell 'account does not exist' (a 404 that should map to a client error) from a transport failure. Translate Horizon's not-found into a dedicated error class and make withFailover() treat it as terminal instead of retrying it. Refs trustflow-protocol#221
StellarService was wired into the DI graph but unreachable. Add GET /stellar/ledger and GET /stellar/balance/:address, with strkey validation (400) and not-found mapping (404), and register the controller on StellarModule. Closes trustflow-protocol#221
Adds NODE_ENV, API_URL, ADMIN_ADDRESSES, SENTRY_DSN, the RATE_LIMIT_ABUSE_* / RATE_LIMIT_LOCKOUT_SECONDS abuse-detection knobs, IDEMPOTENCY_KEY_TTL_SECONDS and ESCROW_RECONCILIATION_SWEEP_INTERVAL_MS to .env.example, each with a short comment. Closes trustflow-protocol#222
Declares the dev dependencies, a prepare script that installs the git hook, and the lint-staged config (eslint --fix + prettier --write on staged *.ts). Refs trustflow-protocol#225
Runs lint-staged against the backend package (the repo keeps the Node project in backend/ while .git is at the root). Refs trustflow-protocol#225
|
@thefadah 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.
This PR hardens the backend's configuration and connection handling, and covers a few endpoints/knobs that existed in the code but were undocumented or unreachable.
#220 — Redis client resilience
createRedisClient()is now an exported factory (independently testable); the module provider delegates to it.nullwith a warning whenREDIS_URLis unset instead of throwing at construction.error/connect/reconnectinglisteners so a transient failure is logged, not an unhandled event.connect()whose rejection is logged; the client keeps retrying perretryStrategy.#221 — Stellar lookups exposed
StellarAccountNotFoundErrorsogetBalance()distinguishes "account does not exist" (Horizon 404) from a transport failure;withFailover()treats it as terminal.StellarController:GET /stellar/ledgerandGET /stellar/balance/:address, with strkey validation (400) and not-found mapping (404). Registered onStellarModule.#222 —
.env.examplecoverageNODE_ENV,API_URL,ADMIN_ADDRESSES,SENTRY_DSN,RATE_LIMIT_ABUSE_WINDOW_SECONDS,RATE_LIMIT_ABUSE_THRESHOLD,RATE_LIMIT_LOCKOUT_SECONDS,IDEMPOTENCY_KEY_TTL_SECONDS,ESCROW_RECONCILIATION_SWEEP_INTERVAL_MS, each with a short comment.env-example-coverage.spec.tswhich fails if anyprocess.env.Xreferenced underbackend/srcis missing from.env.example.#225 — pre-commit hook
husky+lint-stageddev deps, apreparescript, and alint-stagedconfig (eslint --fix+prettier --writeon staged*.ts).backend/.husky/pre-commitrunslint-stagedagainst the backend package (the repo keeps the Node project inbackend/while.gitis at the root).SETUP_INSTRUCTIONS.mddocuments the hook.Closes #220
Closes #221
Closes #222
Closes #225
Split into 10 commits. Not built or run in this environment.