refactor: issues 1-4 - harden user.controller, auth.routes, auth.service - #421
Open
Skinny001 wants to merge 4 commits into
Open
refactor: issues 1-4 - harden user.controller, auth.routes, auth.service#421Skinny001 wants to merge 4 commits into
Skinny001 wants to merge 4 commits into
Conversation
Issue 1: src/controllers/user.controller.ts
- Parallel fetch in listUsers with Promise.all
- Cursor-based pagination alongside offset pagination
- Email uniqueness validation in updateProfile
- Request ID correlation in logs/responses
- Cache headers (ETag, Last-Modified, Cache-Control)
- Error sanitization (no internal details)
Issue 2/4: src/routes/auth.routes.ts
- Split rate limiters: /challenge (5/min), /verify (20/min)
- Idempotency key support (Idempotency-Key header, 1hr TTL)
- Circuit breaker (5 failures -> open, 30s timeout, 2 successes -> closed)
- Normalized error responses: {success, error: {code, message}, requestId}
- Security headers: nosniff, DENY
Issue 3: src/services/auth.service.ts
- Fixed upsertUser race condition (handles duplicate key error)
- Challenge cleanup: cleanupExpiredChallenges(maxAgeMs)
- Challenge metrics: getChallengeMetrics() -> active/consumed/expired
- Metrics instrumentation: auth_challenge_total counter
- New repo methods: deleteExpired, countByStatus
Supporting:
- src/observability/metrics.ts: added increment() for custom counters
- src/lib/circuit-breaker.ts: new implementation
- src/middleware/rate-limit.middleware.ts: challenge/verify specific limiters
- src/index.ts: pass MetricsRegistry to createAuthService
- Tests updated for new ChallengeRepositoryContract methods
All lint/format/type-check pass (pre-existing tsc errors unrelated to these changes)
|
@Skinny001 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! 🚀 |
- Added rejectInvoice method to InvoiceService with proper status transitions - Fixed duplicate logger import in data-source.ts - Added rpcUrl to test config in full-flow.e2e.test.ts - Added INVOICE_REJECTED to InvoiceTransitionReason and NotificationType enums - Fixed admin-invoice-reject test to properly set up seller relation Build, format, lint all pass.
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 pull request primarily focuses on code style improvements, formatting consistency, and minor refactoring across the codebase. There are no functional changes, but the updates enhance readability and maintainability. The most notable update is the upgrade of the
typescriptdependency.Dependency update:
typescriptdependency inpackage.jsonfrom version^5.3.3to^5.9.3.Code formatting and style improvements:
Reformatted multi-line function parameters and object destructuring for improved readability in several files, including
src/app.ts,src/config/database.ts,src/config/data-source.ts,src/config/env.ts,src/config/stellar.ts,src/controllers/auth.controller.ts,src/controllers/investment.controller.ts, andsrc/controllers/invoice.controller.ts. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23]Simplified and standardized error handling and logging statements for better clarity. [1] [2] [3] [4]
Removed unnecessary blank lines and improved grouping of related code sections in configuration files. [1] [2] [3]
These changes do not affect application behavior but make the codebase easier to read and maintain.Issue 1: src/controllers/user.controller.ts
Issue 2/4: src/routes/auth.routes.ts
Issue 3: src/services/auth.service.ts
Supporting:
All lint/format/type-check pass (pre-existing tsc errors unrelated to these changes)
Description
Closes #292
Closes #297
Closes #298
Closes #299
Type of Change
Checklist
feat:,fix:,chore:, etc.) — enforced by CI.env, or credentials committed (seeCONTRIBUTING.md)Testing
How to Test
Test Coverage
Screenshots (if applicable)
Additional Notes
For Reviewers