Skip to content

feat(board): add board sync list and bulk fetch by ids endpoints#466

Merged
tomivm merged 1 commit into
masterfrom
feat/board-sync-api
Jun 5, 2026
Merged

feat(board): add board sync list and bulk fetch by ids endpoints#466
tomivm merged 1 commit into
masterfrom
feat/board-sync-api

Conversation

@RodriSanchez1

Copy link
Copy Markdown
Collaborator

Summary

Adds the backend needed for efficient diff-based board sync, supporting the frontend work in cboard-org/cboard#2213 (PR cboard-org/cboard#2214).

Instead of fetching every board in full or calling GET /board/{id} once per board (N round-trips), a client can now:

  1. Call GET /board/sync/{email} → get a lightweight { id, lastEdited } list of all the user's boards.
  2. Diff it against its local copy to find which boards changed.
  3. Call POST /board/byids with just the changed ids → fetch those full boards in a single request.

Changes

  • GET /board/sync/{email} (getBoardsSync) — lightweight change list.
  • POST /board/byids (getBoardsByIds) — bulk fetch full boards by id.
  • Board model — indexes on email and { email, lastEdited, _id } to back the sync queries.
  • Swagger definitions for both endpoints (BoardsByIdsRequest, GetBoardsByIdsResponse).
  • Controller tests for both endpoints.

Security / safety

  • Both endpoints require a Bearer token (admin / user scopes).
  • Non-admin callers are scoped to their own boards by email.
  • POST /board/byids filters out invalid ObjectIds and caps the request at 3000 ids, enforced in the controller — swagger does not validate array maxItems on request bodies, so the cap must live in code.

Notes for reviewers

  • /board/byids is declared in the swagger spec before /board/{id} so the literal path resolves ahead of the {id} template under swagger-tools routing. Keep that ordering.
  • This swagger setup does not enforce array minItems/maxItems on bodies; size/shape constraints are validated in the controller.

Test plan

  • npm test (board controller suite) — auth, admin-only access to other users' data, ObjectId filtering, size cap, non-admin isolation.

Refs cboard-org/cboard#2213, cboard-org/cboard#2214
Closes #465

Add the backend needed for efficient diff-based board sync:

- GET /board/sync/{email}: lightweight { id, lastEdited } list so the
  client can detect which boards changed.
- POST /board/byids: returns full boards for a set of ids, letting the
  client fetch only changed boards in one request instead of N calls to
  GET /board/{id}.
- Board model: index email and { email, lastEdited, _id } to back the
  sync queries.

Security: both endpoints require a Bearer token and scope non-admin
callers to their own boards. /board/byids drops invalid ObjectIds and
caps the request at 3000 ids in the controller (swagger does not
validate array maxItems on bodies).

Adds controller tests for both endpoints.

Refs cboard-org/cboard#2213, cboard-org/cboard#2214
Closes #465

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@RodriSanchez1 RodriSanchez1 requested review from magush27 and tomivm June 4, 2026 00:54
@tomivm tomivm merged commit f2e47f9 into master Jun 5, 2026
2 checks passed
@tomivm tomivm deleted the feat/board-sync-api branch June 5, 2026 17:22
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.

Add efficient board sync API: lightweight sync list + bulk fetch by ids

2 participants