mufidu / booku

0 stars 1 forks source link

Sweep: Refactor delete user endpoint to use request body #111

Closed mufidu closed 5 months ago

mufidu commented 5 months ago

Details

Refactor delete user endpoint in (routes/user.routes.js) to modify the route handler to extract the ID from the request body instead of the URL. Adjust the test case (test/user.test.js) accordingly.

Checklist - [X] Modify `routes/user.routes.js` ✓ https://github.com/mufidu/booku/commit/95ab5a6a09ec14964bf1b7684155d02eee86778f [Edit](https://github.com/mufidu/booku/edit/sweep/refactor_delete_user_endpoint_to_use_req/routes/user.routes.js) - [X] Running GitHub Actions for `routes/user.routes.js` ✓ [Edit](https://github.com/mufidu/booku/edit/sweep/refactor_delete_user_endpoint_to_use_req/routes/user.routes.js) - [X] Modify `test/user.test.js` ✓ https://github.com/mufidu/booku/commit/45330109da8cf17f553c851a41946d5923de7cad [Edit](https://github.com/mufidu/booku/edit/sweep/refactor_delete_user_endpoint_to_use_req/test/user.test.js) - [X] Running GitHub Actions for `test/user.test.js` ✓ [Edit](https://github.com/mufidu/booku/edit/sweep/refactor_delete_user_endpoint_to_use_req/test/user.test.js)
sweep-ai[bot] commented 5 months ago

🚀 Here's the PR! #112

See Sweep's progress at the progress dashboard!
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: 49d64d383f)

[!TIP] I can email you next time I complete a pull request if you set up your email here!


Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/mufidu/booku/blob/775dda8835daa9e03ebbb6ed705b27545363ca6a/routes/user.routes.js#L1-L17 https://github.com/mufidu/booku/blob/775dda8835daa9e03ebbb6ed705b27545363ca6a/test/user.test.js#L1-L45

Step 2: ⌨️ Coding

--- 
+++ 
@@ -5,7 +5,7 @@

 router.delete('/:id', async (req, res) => {
   try {
-    const deletedUser = await User.findByIdAndDelete(req.params.id);
+    const deletedUser = await User.findByIdAndDelete(req.body.id);
     if (!deletedUser) {
       return res.status(404).send('User not found');
     }

Ran GitHub Actions for 95ab5a6a09ec14964bf1b7684155d02eee86778f:

--- 
+++ 
@@ -30,8 +30,9 @@

   it("should delete the user with authentication", async () => {
     const res = await chai.request(app)
-      .delete(`/users/${userId}`)
-      .set("Authorization", `Bearer ${token}`);
+      .delete('/users')
+      .set("Authorization", `Bearer ${token}`)
+      .send({ id: userId });

     expect(res).to.have.status(200);
     expect(res.body).to.equal('\"User deleted successfully\"');

Ran GitHub Actions for 45330109da8cf17f553c851a41946d5923de7cad:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/refactor_delete_user_endpoint_to_use_req.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.

This is an automated message generated by Sweep AI.