Skip to content

feat(idurar-erp-crm): add DTO layer to strip internal fields from API responses#866

Draft
augmentcode[bot] wants to merge 1 commit into
mainfrom
hammads-turing/add-dto-layer
Draft

feat(idurar-erp-crm): add DTO layer to strip internal fields from API responses#866
augmentcode[bot] wants to merge 1 commit into
mainfrom
hammads-turing/add-dto-layer

Conversation

@augmentcode

@augmentcode augmentcode Bot commented Jun 18, 2026

Copy link
Copy Markdown

Problem

All CRUD controller methods returned raw Mongoose documents directly, which exposed internal MongoDB/Mongoose fields — __v (version key) and removed (soft-delete flag) — to API clients. These are implementation details that have no business value for consumers.

Solution

Added a minimal sanitizeDocument utility (backend/src/utils/sanitizeResponse.js) that converts a Mongoose document (or array) to a plain object and strips __v and removed. Applied centrally across all controller response paths:

  • createCRUDControllercreate, read, update, remove, listAll, paginatedList, search, filter
  • invoiceControllercreate, update, read, remove, paginatedList
  • paymentControllercreate, update, remove

_id is preserved so existing frontend references continue to work.


Pull Request opened by Augment Code | View session

Introduce a sanitizeDocument utility (backend/src/utils/sanitizeResponse.js)
and apply it across all controller response paths to remove the Mongoose
version key (__v) and the soft-delete flag (removed) before data is sent
to clients.

Affected controllers:
- createCRUDController: create, read, update, remove, listAll,
  paginatedList, search, filter
- invoiceController: create, update, read, remove, paginatedList
- paymentController: create, update, remove
@augmentcode

augmentcode Bot commented Jun 18, 2026

Copy link
Copy Markdown
Author

PR Author Agent

👋 I've got this PR.

I'll handle review feedback, CI failures, and merge conflicts, and ping you the moment it's ready for review. Drop a comment anytime.

Marking it ready and picking reviewers are your call — I'll leave both alone.

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.

1 participant