veza/veza-backend-api/internal/core
senke b528050afa refactor(backend): extract upload + collaborators into sibling files
Two more cohesive blocks lifted out of monolithic files following the
same recipe as the marketplace refund split (commit 36ee3da1).

internal/core/track/service.go : 1639 → 1026 LOC
  Extracted to service_upload.go (640 LOC) :
    UploadTrack                       (multipart entry point)
    copyFileAsync                     (local/s3 dispatcher)
    copyFileAsyncLocal                (FS write path)
    copyFileAsyncS3                   (direct S3 stream path, v1.0.8)
    chunkStreamer interface           (helper for chunked → S3)
    CreateTrackFromChunkedUploadToS3  (v1.0.9 1.5 fast path)
    extFromContentType                (helper)
    MigrateLocalToS3IfConfigured      (post-assembly migration)
    mimeTypeForAudioExt               (helper)
    updateTrackStatus                 (status updater)
    cleanupFailedUpload               (rollback helper)
    CreateTrackFromPath               (no-multipart constructor)
  Removed `internal/monitoring` import from service.go (the only user
  was the upload path).

internal/handlers/playlist_handler.go : 1397 → 1107 LOC
  Extracted to playlist_handler_collaborators.go (309 LOC) :
    AddCollaboratorRequest, UpdateCollaboratorPermissionRequest DTOs
    AddCollaborator, RemoveCollaborator,
    UpdateCollaboratorPermission, GetCollaborators handlers
  All four handlers were a self-contained surface (one route group,
  one DTO pair, no shared helpers with the rest of the file).

Tests run after each split :
  go test ./internal/core/marketplace -short  →  PASS
  go test ./internal/core/track       -short  →  PASS
  go test ./internal/handlers          -short →  PASS

The dette-tech split target was three files at 1.7k+ / 1.6k+ / 1.4k+
LOC. After this commit + 36ee3da1 :
  marketplace/service.go            : 1737 → 1340  (-397)
  track/service.go                  : 1639 → 1026  (-613)
  handlers/playlist_handler.go      : 1397 → 1107  (-290)
  total reduction  : 4773 → 3473    (-1300, -27%)

Each receiver still has a clear "main" file ; the extracted siblings
encapsulate one concern apiece. Future splits should follow the same
naming pattern (service_<concern>.go,
playlist_handler_<concern>.go) so a quick `ls` shows the file
organisation matches the feature surface.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 04:10:43 +02:00
..
admin feat(v0.11.3): F421-F424 admin platform handler and routes 2026-03-10 18:19:45 +01:00
analytics fix(v0.12.6): apply all pentest remediations — 36 findings across 36 files 2026-03-14 00:44:46 +01:00
auth feat(auth): defer JWT to post-verify + verify-email header (v1.0.9 items 1.3+1.4) 2026-04-26 22:56:31 +02:00
collaboration adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
connecterrors feat(marketplace): stripe reversal error disambiguation + CHECK constraint + E2E — v1.0.7 item B day 3 2026-04-18 02:12:03 +02:00
discover style(backend): gofmt -w on 85 files (whitespace only) 2026-04-14 12:22:14 +02:00
distribution feat(subscription): recovery endpoint + distribution gate (v1.0.9 item G — Phase 3) 2026-04-27 11:33:40 +02:00
education style(backend): gofmt -w on 85 files (whitespace only) 2026-04-14 12:22:14 +02:00
feed feat(v0.10.1): Tags & Genres discover - F351-F355 2026-03-09 01:52:56 +01:00
marketplace refactor(marketplace): extract refund flow into service_refunds.go 2026-05-01 04:05:44 +02:00
moderation feat(v0.11.2): F411-F420 moderation handler and routes 2026-03-10 17:49:51 +01:00
social fix(v0.12.6): apply all pentest remediations — 36 findings across 36 files 2026-03-14 00:44:46 +01:00
subscription feat(subscription): recovery endpoint + distribution gate (v1.0.9 item G — Phase 3) 2026-04-27 11:33:40 +02:00
track refactor(backend): extract upload + collaborators into sibling files 2026-05-01 04:10:43 +02:00