Skip to content

Refactored patch js files#63

Open
joeljoby02 wants to merge 3 commits intomainfrom
patch-refactor
Open

Refactored patch js files#63
joeljoby02 wants to merge 3 commits intomainfrom
patch-refactor

Conversation

@joeljoby02
Copy link
Copy Markdown
Collaborator

Summary

Refactored PATCH controllers to eliminate ~300 lines of duplicated code by creating a shared patchBase.js module that handles common logic for ID validation, database operations, and response formatting.

Changes

  • Created patchBase.js with consolidated PATCH operation logic
  • Refactored patchSet.js, patchUnset.js, and patchUpdate.js to use the base function
  • Updated db-controller.js imports and fixed test syntax issues


// Mount our own /patch route without auth that will use controller.patch
routeTester.use("/patch", [addAuth, controller.patchUpdate])
routeTester.use("/patch", [limiter, addAuth, controller.patchUpdate])
// Mount our own /create route without auth that will use controller.create
routeTester.use("/set", [addAuth, controller.patchSet])
// Mount our own /set route without auth that will use controller.patchSet
routeTester.use("/set", [limiter, addAuth, controller.patchSet])
// Mount our own /create route without auth that will use controller.create
routeTester.use("/unset", [addAuth, controller.patchUnset])
// Mount our own /unset route without auth that will use controller.patchUnset
routeTester.use("/unset", [limiter, addAuth, controller.patchUnset])
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.

2 participants