Skip to content

[Backend] Stellar Wave — upload expiry, MIME validation, WebSocket tx status, migration rollback - #871

Merged
Ceejaytech25 merged 8 commits into
ceejaylaboratory:mainfrom
10xwhoman:feat/stellar-wave-issues-740-746-747-749
Aug 1, 2026
Merged

[Backend] Stellar Wave — upload expiry, MIME validation, WebSocket tx status, migration rollback#871
Ceejaytech25 merged 8 commits into
ceejaylaboratory:mainfrom
10xwhoman:feat/stellar-wave-issues-740-746-747-749

Conversation

@10xwhoman

Copy link
Copy Markdown
Contributor

Summary

Covers four Stellar Wave backend issues.


#740 — TTL expiry scheduler for temporary document uploads

  • storage-provider.service.ts: added deleteObject(key) to interface + Mock/S3/GCS implementations
  • upload-store.service.ts: added EXPIRED_DELETED status
  • upload-expiry.scheduler.ts: added expireDbUploads() — queries DB for isTemporary=true records >30 days old, deletes from storage, marks EXPIRED_DELETED; keeps in-memory fallback
  • prisma/schema.prisma: added isTemporary flag and composite index
  • Migration SQL included

Closes #740


#746 — Strict MIME-type validation for KYC uploads

  • storage-provider.service.ts: MAX_UPLOAD_SIZE_BYTES, validateUploadSize(size), validateKycUpload(buffer, declaredMimeType) — checks magic bytes (JPEG ff d8 ff, PNG 89 50 4e 47, PDF %PDF)
  • 11 new tests covering valid types, mismatched MIME, unsupported types, size limits

Closes #746


#747 — WebSocket server for real-time transaction status

  • backend/src/lib/socket.ts (new): initSocket(httpServer), emitTxUpdated(payload), JWT auth middleware
  • backend/src/index.ts: wraps Express in http.createServer, calls initSocket, listens on httpServer
  • backend/src/api/routes/transactions.route.ts: PATCH /api/transactions/:id/status updates DB and emits tx_updated
  • package.json: added socket.io ^4.8.1 (run npm install after merging)

Closes #747


#749 — Migration rollback with FK integrity verification

  • backend/scripts/rollback.ts (new): RollbackVerifier — checks FK violations via PRAGMA foreign_key_check, prints report, applies rollback; supports --force and --dry-run
  • package.json: added migrate:rollback:verify script
  • docs/MIGRATION_INTEGRITY.md: added Rollback Verification Procedure section

Closes #749

… after 30 days

- Add UploadRecord model to schema with isTemporary flag and composite index
- Add migration to add isTemporary column to existing UploadRecord table
- Add deleteObject(key) to StorageProvider interface with implementations
  for MockStorageProvider, S3StorageProvider, and GcsStorageProvider
- Add EXPIRED_DELETED to UploadStatus union type
- Extend UploadExpiryScheduler with expireDbUploads() that queries DB for
  temporary records older than 30 days, deletes storage objects, and marks
  status as EXPIRED_DELETED; keeps in-memory expireStale() as fallback
@Ceejaytech25

Copy link
Copy Markdown
Contributor

Nice implementation, LGTM!

@Ceejaytech25

Copy link
Copy Markdown
Contributor

Merged via main branch update.

@Ceejaytech25
Ceejaytech25 merged commit cbed005 into ceejaylaboratory:main Aug 1, 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

2 participants