mirror of
https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-service.git
synced 2026-09-21 16:52:03 -07:00
Add DELETE /users/:id
This commit is contained in:
@@ -65,3 +65,22 @@ export async function updateUser(ctx) {
|
||||
ctx.throw(500)
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteUser(ctx) {
|
||||
try {
|
||||
const user = await User.findById(ctx.params.id)
|
||||
if (!user) {
|
||||
ctx.throw(404)
|
||||
}
|
||||
|
||||
await user.remove()
|
||||
|
||||
ctx.body = 200
|
||||
} catch (err) {
|
||||
if (err === 404 || err.name === 'CastError') {
|
||||
ctx.throw(404)
|
||||
}
|
||||
|
||||
ctx.throw(500)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,5 +37,14 @@ export default {
|
||||
ensureUser,
|
||||
user.updateUser
|
||||
]
|
||||
},
|
||||
|
||||
'Delete user': {
|
||||
method: 'DELETE',
|
||||
route: '/:id',
|
||||
handlers: [
|
||||
ensureUser,
|
||||
user.deleteUser
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user