Skip to content

feat(users): add user bookmarks CRUD with ownership and duplicate checks - #1757

Merged
Olowodarey merged 1 commit into
Arena1X:mainfrom
abimbolaalabi:fix/user-bookmarks-crud
Aug 27, 2026
Merged

feat(users): add user bookmarks CRUD with ownership and duplicate checks#1757
Olowodarey merged 1 commit into
Arena1X:mainfrom
abimbolaalabi:fix/user-bookmarks-crud

Conversation

@abimbolaalabi

Copy link
Copy Markdown
Contributor

Overview

This PR adds the missing User Bookmarks CRUD endpoints. The \user_bookmarks\ table and a list endpoint already existed, but create/delete endpoints with ownership enforcement and duplicate rejection were missing, so users could not fully manage their bookmarks securely.

Related Issue

Closes #1644

Changes

  • [ADD] \�ackend/src/users/dto/create-bookmark.dto.ts\
    • \CreateBookmarkDto\ requiring a UUID \market_id.
  • [MODIFY] \�ackend/src/users/users.service.ts\
    • \�ddBookmark(userId, marketId)\ — verifies the market exists (\404), rejects duplicate bookmarks of the same market (\409 Conflict), and creates the bookmark scoped to the authenticated user.

    • emoveBookmark(userId, bookmarkId)\ — scopes the lookup to the caller's \userId, so another user's bookmark is indistinguishable from a missing one (\404).
  • [MODIFY] \�ackend/src/users/users.controller.ts\
    • \POST /users/me/bookmarks\ (\201) — bookmark a market for the current user.
    • \DELETE /users/me/bookmarks/:id\ — remove a bookmark owned by the current user.
    • The existing \GET /users/me/bookmarks\ list endpoint is unchanged.
  • [ADD] \�ackend/src/users/users.service.spec.ts\ + \users.controller.spec.ts\
    • Tests: ownership enforced (another user's bookmark → \404); duplicates rejected (\409).

The DB-level unique index on (user_id, market_id)\ (existing migration + entity) backs the duplicate prevention.

Verification Results

\
pnpm run test # 111 suites / 1414 tests passed
pnpm run build # passed
pnpm run migration:check-timestamps # passed
eslint changed files # no new errors
\\

Acceptance Criteria

Criteria Status
Users manage their bookmarks securely ✅ create/list/delete scoped to the authenticated user with ownership checks
Covered by tests ✅ ownership enforced + duplicates rejected (unit tests)

The user_bookmarks table and a list endpoint existed, but create/delete
endpoints with ownership enforcement and duplicate rejection were missing.

- Add POST /users/me/bookmarks (CreateBookmarkDto) scoped to the
  authenticated user; returns 409 Conflict on a duplicate bookmark and
  404 when the market does not exist.
- Add DELETE /users/me/bookmarks/:id scoped to the authenticated user so
  another user's bookmark is indistinguishable from a missing one (404).
- Add UsersService.addBookmark/removeBookmark with ownership + duplicate
  checks aligned with the DB unique index on (user_id, market_id).
- Add unit tests covering ownership enforcement and duplicate rejection.
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@abimbolaalabi 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

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
insight-arena-4rll Ready Ready Preview Aug 27, 2026 5:53pm

@Olowodarey
Olowodarey merged commit 5aba959 into Arena1X:main Aug 27, 2026
5 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.

[Backend] — User Bookmarks CRUD Endpoint

2 participants