Skip to content

standardized-subscription#352

Merged
OlufunbiIK merged 1 commit intoOlufunbiIK:mainfrom
Xaxxoo:standardized-subscription
Mar 29, 2026
Merged

standardized-subscription#352
OlufunbiIK merged 1 commit intoOlufunbiIK:mainfrom
Xaxxoo:standardized-subscription

Conversation

@Xaxxoo
Copy link
Copy Markdown
Contributor

@Xaxxoo Xaxxoo commented Mar 29, 2026

Closes #345

Summary by CodeRabbit

  • New Features
    • Artists can create and manage subscription tiers with pricing, billing cycles, and descriptions
    • Fans can subscribe to artist tiers with transaction tracking and manage active subscriptions
    • Subscription statuses now tracked across active, cancelled, expired, and pending states
    • Wallet-based JWT authentication support added for secure account access

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 29, 2026

@Xaxxoo is attempting to deploy a commit to the olufunbiik's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 29, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR introduces a complete subscription management system enabling artists to create and manage subscription tiers and fans to subscribe to them. It includes DTOs for request validation, TypeORM entities with relationships, JWT authentication via a WalletStrategy and @CurrentUser() decorator, a service layer with authorization enforcement, a REST controller with CRUD operations, and comprehensive test coverage.

Changes

Cohort / File(s) Summary
Data Transfer Objects
backend/src/standardized-subscription/create-subscription-tier.dto.ts, backend/src/standardized-subscription/update-subscription-tier.dto.ts, backend/src/standardized-subscription/subscribe-fan.dto.ts, backend/src/standardized-subscription/subscribe-fan.dto (1).ts
DTO classes for tier creation/updates and fan subscription requests, with Swagger metadata and class-validator constraints.
Database Entities
backend/src/standardized-subscription/subscription-tier.entity.ts, backend/src/standardized-subscription/fan-subscription.entity.ts
TypeORM entities defining SubscriptionTier, FanSubscription, and SubscriptionStatus enum, with composite indexes, relationships, and database-level constraints.
Authentication & Authorization
backend/src/standardized-subscription/current-user.decorator.ts, backend/src/standardized-subscription/wallet.strategy.ts
@CurrentUser() parameter decorator extracting authenticated principals; WalletStrategy implementing JWT validation with optional artistId resolution and principal construction.
Service & Module
backend/src/standardized-subscription/subscriptions.service.ts, backend/src/standardized-subscription/subscriptions.module.ts
SubscriptionsService with methods for tier CRUD (artist-owned), fan subscription lifecycle, and ownership/role enforcement; SubscriptionsModule wiring repositories and providers.
Controller
subscriptions.controller.ts
SubscriptionsController exposing REST endpoints for tier management (POST, PATCH, DELETE) and fan subscription actions (POST /subscribe, DELETE /cancel, GET /me), with auth guards and Swagger documentation.
Test Suites
backend/src/standardized-subscription/subscriptions.service.spec.ts, backend/src/standardized-subscription/subscriptions.controller.spec.ts
Jest tests validating service logic (tier ownership, duplicate subscriptions, authorization), controller delegation, and principal handling across all subscription flows.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Controller as SubscriptionsController
    participant Guard as AuthGuard<br/>(wallet-jwt)
    participant Strategy as WalletStrategy
    participant Service as SubscriptionsService
    participant Repo as FanSubscription<br/>Repository

    Client->>Guard: POST /subscription-tiers/:tierId/subscribe<br/>Bearer Token
    Guard->>Strategy: Extract & validate JWT
    Strategy->>Strategy: Verify signature & expiry
    Strategy->>Strategy: Resolve artistId from db<br/>(if user is artist)
    Strategy-->>Guard: AuthenticatedPrincipal<br/>{id, walletAddress, roles}
    Guard-->>Controller: req.user = principal
    Controller->>Service: subscribe(tierId, dto,<br/>principal)
    Service->>Service: Verify tier exists<br/>& is active
    Service->>Service: Check no active<br/>subscription exists<br/>for (fanUserId, tierId)
    Service->>Repo: Save new FanSubscription<br/>{fanUserId: principal.id,<br/>tierId, status: PENDING,<br/>paymentTxId, expiresAt}
    Repo-->>Service: FanSubscription created
    Service-->>Controller: FanSubscription
    Controller-->>Client: 201 Created<br/>FanSubscription
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 Hop, hop—tiers for artists now bloom,
Fans subscribe with a wallet's boom!
JWTs unwrap the identity's truth,
Ownership guards keep artists aloof. 🎫✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'standardized-subscription' is vague and generic, using a single term that doesn't convey specific information about the main changes implemented. Consider a more descriptive title like 'Add standardized subscription-tier management with artist ownership and fan subscription flows' to better communicate the scope of changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR implements all key requirements from issue #345: removes embedded /api route drift (new controller mounted at 'subscription-tiers'), enforces artist-tier ownership checks via assertTierOwnership and requireArtist helpers, ensures fan-subscription flows use correct identity (principal.id for fanUserId, principal.artistId for artist), and provides comprehensive test coverage for all flows with auth enforcement.
Out of Scope Changes check ✅ Passed The PR introduces a new standardized subscription module with entities, DTOs, service, controller, strategy, and decorator—all directly aligned with the linked issue scope of standardizing routes, ownership checks, and authentication flows. No unrelated changes detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@OlufunbiIK OlufunbiIK merged commit 62f81bd into OlufunbiIK:main Mar 29, 2026
0 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.

Standardize subscription-tier routes and authenticated artist ownership

2 participants