Skip to content

feat: add routes-f rewards endpoints#503

Open
Obiajulu-gif wants to merge 1 commit intoStreamFi-x:devfrom
Obiajulu-gif:codex/feat-routes-f-rewards-endpoint
Open

feat: add routes-f rewards endpoints#503
Obiajulu-gif wants to merge 1 commit intoStreamFi-x:devfrom
Obiajulu-gif:codex/feat-routes-f-rewards-endpoint

Conversation

@Obiajulu-gif
Copy link
Copy Markdown

This pull request implements a comprehensive rewards system for users, including database schema, business logic, and API endpoints for rewards balance, redemption, and history. It also adds robust test coverage for these endpoints. The most important changes are grouped below by theme.

Rewards System Core Logic and Database:

  • Introduced a new rewards system in db.ts with reward tiers, definitions, and catalog, as well as logic for syncing reward events (watching, chatting, tipping), calculating balances, and handling atomic transactions for redemption. Includes schema creation and helper utilities.

API Endpoints:

  • Added GET /api/routes-f/rewards endpoint to return the authenticated user's current reward points, lifetime points, and tier, ensuring schema and synchronization before responding.
  • Implemented POST /api/routes-f/rewards/redeem endpoint to allow users to redeem rewards atomically, with validation, transactional safety, and detailed response/error handling.
  • Added GET /api/routes-f/rewards/history endpoint to return paginated reward event history for the user, with support for cursor-based pagination and error handling.

Test Coverage:

  • Added unit tests for the rewards balance endpoint, covering both authenticated and unauthenticated access, and verifying correct synchronization and response structure.
  • Added unit tests for the rewards redemption endpoint, covering successful redemption, insufficient points, and missing rewards.
  • Added unit tests for the rewards history endpoint, verifying correct ordering, pagination, and error handling for invalid parameters.

Closes #455

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 28, 2026

@Obiajulu-gif 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
Copy link
Copy Markdown

drips-wave bot commented Mar 28, 2026

@Obiajulu-gif 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

@Obiajulu-gif
Copy link
Copy Markdown
Author

@Depo-dev @claude please merge my code

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.

feat(routes-f): viewer loyalty rewards endpoint

1 participant