Skip to content

Add POST /shipments/:id/tags and DELETE /shipments/:id/tags/:tag — atomic granular tag management #128

Description

@shakurJJ

Summary

PATCH /shipments/:id allows replacing the entire tags array, but there is no way to add or remove individual tags without reading the current list first and sending the full replacement array. For concurrent clients this creates a race condition. Dedicated tag add/remove endpoints solve this atomically at the DB level.

Location

src/modules/shipments/shipments.controller.ts — add POST :id/tags and DELETE :id/tags/:tag
src/modules/shipments/shipments.service.ts — add addTag() using Prisma push and removeTag() using prisma.$executeRaw array_remove

Expected Behaviour

  1. POST /shipments/:id/tags body: { tag: string }. Validates tag is non-empty, max 50 chars, no spaces. Appends using { push: [tag] }. Returns 409 if tag already exists.
  2. DELETE /shipments/:id/tags/:tag removes the tag using array_remove SQL. Returns 404 if the tag is not present.
  3. Both endpoints restricted to the shipment's buyerAddress and only allowed when shipment is ACTIVE.
  4. Return the updated tags array after each operation.

Acceptance Criteria

  • Adding an existing tag returns 409
  • Removing a non-existent tag returns 404
  • Both operations are atomic at the database level
  • Only the buyer can modify tags; others receive 403

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave programenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions