Skip to content

Admin Subscription Plan Endpoints #44

Description

@codebestia

Background

SubscriptionPlan and Subscription already exist in the schema (fields match the contract's structs — id, planId, merchantId, description, token, amount, interval, active for plans) — no new schema is needed for this issue.

Proposed Steps

  1. GET /admin/subscription-plans — paginated, filterable by merchantAddress (join), token, active (bool), sortable by sortBy in [createdAt, amount, interval] / sortDir.
  2. GET /admin/subscription-plans/:id — plan detail, including a subscriberCount (via Prisma's _count on the subscriptions relation) since an admin looking at a plan will reasonably want to know how many active subscribers it has without a second request.
  3. Tests, as explicitly requested: tests/unit/admin.subscription-plan.services.test.ts (filter/sort/pagination logic) and tests/integration/admin.subscription-plan.routes.test.ts (route-level, following the existing mocked-Prisma pattern used throughout tests/integration/).

Acceptance Criteria

  • GET /admin/subscription-plans supports all listed filters, sort options, and pagination
  • GET /admin/subscription-plans/:id includes subscriberCount; 404 for unknown id
  • Unit tests cover the filter/sort/pagination parsing logic in isolation
  • Integration tests cover the routes end-to-end against a mocked Prisma client, matching the existing test suite's conventions
  • No new Prisma models or fields required

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions