Skip to content

feat: add follow endpoint with integration tests - #776

Merged
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
Emeka-12:feature/follow-integration-test
Aug 25, 2026
Merged

feat: add follow endpoint with integration tests#776
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
Emeka-12:feature/follow-integration-test

Conversation

@Emeka-12

Copy link
Copy Markdown

Summary

Add integration tests for the follow/unfollow endpoints to verify correct follower count incrementing and decrementing behavior. This also includes the implementation of the follow feature itself.

closes #697, closes #698, closes #699, closes #700

Changes

Schema

  • Added Follow Prisma model with unique constraint on (followerAddress, creatorId)
  • Added followersCount field to CreatorProfile model (default: 0)

Implementation

  • Follow Service (follow.service.ts): Idempotent follow/unfollow logic with atomic transactions
  • Follow Handlers (follow.handlers.ts): Express handlers for POST/DELETE endpoints
  • Follow Routes (creator.routes.ts): Added routes with Stellar signature authentication

Integration Tests

  • Follow increments count by 1: POST to follow endpoint returns 201 with followersCount: 1
  • Double follow is idempotent: Second follow returns 200 with action: 'already_following', count unchanged
  • Unfollow decrements count by 1: DELETE returns 200 with followersCount: 0
  • Double unfollow is idempotent: Second unfollow returns 200 with action: 'not_following', count stays 0
  • Unauthenticated follow returns 401: Request without wallet headers returns UNAUTHORIZED
  • Non-existent creator returns 404: Follow attempt on missing creator returns NOT_FOUND

Endpoints Added

Method Path Description
POST /api/v1/creators/:creatorId/follow Follow a creator (idempotent)
DELETE /api/v1/creators/:creatorId/follow Unfollow a creator (idempotent)

Both endpoints require Stellar signature authentication (x-wallet-address, x-wallet-signature, x-timestamp headers).

Test Results

All 6 integration tests pass:

PASS src/modules/creator/follow.integration.test.ts
  POST/DELETE /api/v1/creators/:creatorId/follow — follower count
    ✓ increments follower count by 1 on follow
    ✓ does not increment count on double follow (idempotent)
    ✓ decrements follower count by 1 on unfollow
    ✓ does not decrement count below 0 on double unfollow (idempotent)
    ✓ returns 401 for unauthenticated follow request
    ✓ returns 404 when creator does not exist

Add follow/unfollow endpoints for creators with idempotent behavior
and follower count tracking.

Changes:
- Add Follow Prisma model with unique constraint on (followerAddress, creatorId)
- Add followersCount field to CreatorProfile model
- Create follow service with idempotent follow/unfollow logic
- Create follow handlers for POST and DELETE endpoints
- Add follow routes to creator router
- Add comprehensive integration tests covering:
  - Follow increments count by 1
  - Double follow is idempotent (count not incremented twice)
  - Unfollow decrements count by 1
  - Double unfollow is idempotent (count does not go below 0)
  - Unauthenticated follow returns 401
  - Non-existent creator returns 404
@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

@Emeka-12 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

@Chucks1093
Chucks1093 merged commit 2e2a962 into accesslayerorg:main Aug 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment