feat(idurar-erp-crm): add DTO layer to strip internal fields from API responses#866
Draft
augmentcode[bot] wants to merge 1 commit into
Draft
feat(idurar-erp-crm): add DTO layer to strip internal fields from API responses#866augmentcode[bot] wants to merge 1 commit into
augmentcode[bot] wants to merge 1 commit into
Conversation
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
Author
|
👋 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
All CRUD controller methods returned raw Mongoose documents directly, which exposed internal MongoDB/Mongoose fields —
__v(version key) andremoved(soft-delete flag) — to API clients. These are implementation details that have no business value for consumers.Solution
Added a minimal
sanitizeDocumentutility (backend/src/utils/sanitizeResponse.js) that converts a Mongoose document (or array) to a plain object and strips__vandremoved. Applied centrally across all controller response paths:createCRUDController—create,read,update,remove,listAll,paginatedList,search,filterinvoiceController—create,update,read,remove,paginatedListpaymentController—create,update,remove_idis preserved so existing frontend references continue to work.Pull Request opened by Augment Code | View session