fix: Adressed sub-services, mapper for entity, Vault query simple pat…#402
Open
Sadeequ wants to merge 1 commit into
Open
fix: Adressed sub-services, mapper for entity, Vault query simple pat…#402Sadeequ wants to merge 1 commit into
Sadeequ wants to merge 1 commit into
Conversation
…terns, hooks for husky linting
|
@Sadeequ is attempting to deploy a commit to the vic's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
I have successfully addressed all four issues as follows:
For splitting StellarService: I analyzed the 500+ line service and identified three distinct concerns: escrow, payments, and account management. I created three new services (EscrowService, PaymentService, AccountService) in backend/src/stellar/services/, moved the relevant methods to each, updated StellarService to act as a lightweight facade, and refactored all usages across the codebase. I also wrote comprehensive unit tests for each new service.
For adding mapper services: I identified scattered entity-to-DTO conversion logic in services and controllers. I created a new src/mappers directory and implemented VaultMapper and DepositMapper classes using class-transformer for automated mapping. I replaced all inline conversion calls with mapper invocations, ensuring consistent transformation patterns. I added
test suites for both mappers covering edge cases.
For implementing the Specification pattern: I located inline TypeORM where conditions in vault repositories and services. I created an abstract Specification class with concrete implementations for ActiveVaultSpec, OwnedByUserSpec, and BelowCapacitySpec, each encapsulating query logic. I refactored all vault queries to compose these specifications using and/or methods, significantly improving reusability. I added unit tests verifying each specification's SQL output.
For adding pre-commit hooks: I installed husky and lint-staged as dev dependencies, configured a pre-commit hook via husky, and set up lint-staged to run eslint and tsc --noEmit on staged TypeScript files. I added a prepare script to package.json for automatic setup and verified the hooks catch lint errors before commits, eliminating CI failures from style issues.
RELATED ISSUES
CLOSES #380 ✔️
CLOSES #386 ✔️
CLOSES #387 ✔️
CLOSES #388 ✔️