Skip to content

Implement GET /api/routes-d/kyc/status endpoint#1078

Merged
davedumto merged 3 commits into
davedumto:mainfrom
0xdevmes:feature/routes-d-kyc-status
Jun 24, 2026
Merged

Implement GET /api/routes-d/kyc/status endpoint#1078
davedumto merged 3 commits into
davedumto:mainfrom
0xdevmes:feature/routes-d-kyc-status

Conversation

@0xdevmes

Copy link
Copy Markdown
Contributor

Implement GET /api/routes-d/kyc/status endpoint

Summary

This PR implements a GET endpoint to fetch the KYC application status for an authenticated user. The endpoint returns the current status of the user's KYC application, including relevant details like level, submission timestamps, and rejection reasons if applicable.

Implementation

Endpoint: GET /api/routes-d/kyc/status

Response Structure:

  • When no application exists: { status: "not_submitted", application: null }
  • When application exists: { status: <status>, application: { <application_details> } }

Application Details Returned:

  • id - Application UUID
  • status - Current status (pending, approved, rejected)
  • level - KYC level (basic, enhanced)
  • fullName - Applicant's full name
  • submittedAt - Timestamp when application was submitted
  • reviewedAt - Timestamp when application was reviewed (null if not reviewed)
  • rejectionReason - Reason for rejection (null if not rejected)
  • createdAt - Application creation timestamp
  • updatedAt - Last update timestamp

Authentication & Authorization:

  • Requires valid Bearer token in Authorization header
  • Returns 401 if token is missing or invalid
  • Returns 404 if user is not found in database

Error Handling:

  • Structured error responses with appropriate HTTP status codes
  • Try-catch block returns 500 for unexpected errors
  • Logger integration for error tracking

Testing

Added comprehensive unit tests in tests/api.routes-d.kyc.status.test.ts (8 tests):

  1. returns 401 when no auth is supplied - Verifies authentication requirement
  2. returns 401 when token is invalid - Verifies token validation
  3. returns 404 when user is not found - Verifies user lookup
  4. returns not_submitted status when no application exists - Handles no-application case
  5. returns pending application status - Verifies pending state
  6. returns approved application status - Verifies approved state with reviewedAt
  7. returns rejected application status with rejection reason - Verifies rejection handling
  8. selects only required fields from application - Verifies field selection optimization

All tests pass successfully.

Files Changed

  • app/api/routes-d/kyc/status/route.ts - GET handler implementation
  • tests/api.routes-d.kyc.status.test.ts - Unit tests

Design Decisions

  • Used selective field querying to avoid returning sensitive PII (address, DOB, etc.) that are stored in the application but not needed for status checks
  • Returns a clear "not_submitted" status instead of null/undefined to make the API more explicit
  • Follows existing routes-d conventions for authentication, error handling, and response structure
  • Consistent with the existing /api/routes-d/kyc/submit endpoint patterns

Closes #963

- Add GET handler to fetch KYC application status for authenticated user
- Returns 'not_submitted' status when no application exists
- Returns application details with status, level, and relevant timestamps
- Includes authentication, user lookup, and structured error handling
- Add comprehensive unit tests covering all scenarios (8 tests passing)

Closes davedumto#963
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

@0xdevmes is attempting to deploy a commit to the david's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 24, 2026

Copy link
Copy Markdown

@0xdevmes 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! 🚀

Learn more about application limits

@davedumto davedumto merged commit 6eb7627 into davedumto:main Jun 24, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[routes-d] GET /api/routes-d/kyc/status - fetch KYC status

2 participants