refactor: extract feedback logic into MVC structure - #647
Open
manasvisharma2231 wants to merge 1 commit into
Open
refactor: extract feedback logic into MVC structure#647manasvisharma2231 wants to merge 1 commit into
manasvisharma2231 wants to merge 1 commit into
Conversation
Move inline feedback schema and handlers out of index.js into dedicated model, controller, and route files to remove duplication and align with the auth/reports pattern. Fixes lovelymahor#623
|
@manasvisharma2231 is attempting to deploy a commit to the Lovely Mahour's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Move inline feedback schema and handlers out of index.js into dedicated model, controller, and route files to remove duplication and align with the auth/reports pattern.
Fixes #623
Description
This PR resolves #623 — Architecture Inconsistency & Code Duplication (Feedback Logic).
Previously, the Feedback Mongoose schema and route handlers (
POST /api/feedback,GET /api/feedbacks) were defined inline insideserver/index.js, while duplicate logic existed in unused files underserver/src/. This caused code duplication and madeindex.jsunnecessarily bloated.This refactor moves feedback logic into a clean MVC structure, consistent with how auth and reports are organized in the project.
Type of change
Changes made
server/index.jsPOST /api/feedback→ create feedbackGET /api/feedbacks→ list all feedbacksserver/src/routes/feedback.js(new)createRouterandlistRouterfor clean mountingserver/src/controllers/feedback.controller.jscreateFeedback,getFeedbacks)console.logstatementsserver/src/models/feedback.model.jsserver/app.jsfeedback.routes.jsindex.jsserver/src/routes/feedback.routes.jsfeedback.js)Architecture after refactor
index.js → only mounts routes
routes/feedback.js → URL mapping
controller/ → business logic
model/ → database schema
middleware/ → validation
Testing done
Tested locally on backend as per project contributing guidelines:
npm run dev)POST /api/feedback— returns201with success message for valid payloadPOST /api/feedback— returns400for invalid/empty fields (validation middleware)GET /api/feedbacks— returns200with saved feedback arraySample test commands used: