feat: Implement GET /api/credit/lines/:id With Repository + Standardized 404 Handling (#6)#68
Open
Bug-Hunter-X wants to merge 4 commits intoCreditra:mainfrom
Open
Conversation
Contributor
Author
|
@greatest0fallt1me please review and merge |
… into feature/get-credit-line-by-id # Conflicts: # package-lock.json # package.json # src/routes/credit.ts
Contributor
|
@Bug-Hunter-X Can you resolve the conflicts? |
Contributor
Author
@greatest0fallt1me DOne boss |
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.
Overview
Implements
GET /api/credit/lines/:idusing a shared credit line repository and standardized error handling middleware.The route now returns full credit line details on success (
200) and a consistent not-found error body on missing IDs (404).Closes #6
Changes
Core API
[ADD] src/repositories/creditLineRepository.ts
creditLineRepositorywith:getById(id: string): CreditLine | undefinedgetAll(): CreditLine[]CreditLinemodel/store from the credit service.[MODIFY] src/routes/credit.ts
GET /lines/:idnow usescreditLineRepository.getById.CreditLineNotFoundErrorwhen missing and delegates to route error middleware.{ data: <creditLine> }with status200.{ error: 'Credit line "<id>" not found.' }with status404.Tests
[ADD] src/test/creditLineRepository.test.ts
getByIdreturns full object for known ID.getByIdreturnsundefinedfor unknown ID.[MODIFY] src/test/creditRoute.test.ts
Errorand non-Errorthrow to fully cover route error branches.vi) to run in current test runner.Documentation
GET /api/credit/lines/:id, including standardized 404 response shape.Dependencies
supertest,@types/supertest.How to Run Tests
Verification Results
getByIdadded in repository200with full payload on found404standardized error on not found100%lines/branches/functions forsrc/routes/credit.ts)Verification Evidence
npm test -- src/__test__/creditRoute.test.ts src/__test__/creditLineRepository.test.ts2test files passed,25tests passed.npx vitest run src/__test__/creditRoute.test.ts --coverage --coverage.include=src/routes/credit.ts --coverage.reporter=textcredit.ts:100%statements,100%branches,100%functions,100%lines.