-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Delete my profile implemented #54
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you write tests as well? @Danishkar
if (!user || user.uuid !== userId) { | ||
res.status(404).json({ message: 'Profile not found' }) | ||
} else { | ||
await deleteProfile(user) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await deleteProfile(user) | |
await deleteProfile(user.uuid) |
src/services/profile.service.ts
Outdated
@@ -39,3 +39,14 @@ export const updateProfile = async ( | |||
|
|||
return savedProfile | |||
} | |||
|
|||
export const deleteProfile = async (user: Profile): Promise<void> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const deleteProfile = async (user: Profile): Promise<void> => { | |
export const deleteProfile = async (userId: string): Promise<void> => { |
): Promise<void> => { | ||
try { | ||
const userId = req.params.uuid | ||
const user = await getProfile(req) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const user = await getProfile(req) | |
const user = req.user |
Hi @Danishkar, can you fix the conflicts? |
yea sure |
i will work on that |
Can you fix the lint errors as well? Run |
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Danishkar can you run lint fix again? The CI is failing.
@Danishkar the tests are failing |
yea bro I am new to this jest testing I will check on that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requested some changes
res: Response | ||
): Promise<void> => { | ||
try { | ||
const userId = req.params.uuid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const userId = req.params.uuid |
try { | ||
const userId = req.params.uuid | ||
const user = req.user as Profile | ||
if (!user || user.uuid !== userId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!user || user.uuid !== userId) { | |
if (!user) { |
src/routes/profile/profile.route.ts
Outdated
@@ -9,5 +10,6 @@ const profileRouter = express.Router() | |||
|
|||
profileRouter.get('/profile', requireAuth, getProfileHandler) | |||
profileRouter.put('/profile', requireAuth, updateProfileHandler) | |||
profileRouter.delete('/profile/:uuid', requireAuth, deleteProfileHandler) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
profileRouter.delete('/profile/:uuid', requireAuth, deleteProfileHandler) | |
profileRouter.delete('/profile', requireAuth, deleteProfileHandler) |
@Danishkar can you take a pull and fix the lint issues @Danishkar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! @Danishkar
Purpose
The purpose of this PR is to fix #11
Goals
Approach
Screenshots
Checklist
Related PRs
Test environment
Learning