Last active
June 6, 2019 01:36
-
-
Save ktutnik/840d5f01f8d9cbb9e9f54e56bdf021dc to your computer and use it in GitHub Desktop.
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
| export class UsersController { | |
| // ----- other methods removed for clarity | |
| @ownerOrAdmin() | |
| @route.delete(":id") | |
| async delete(id: number, @bind.user() user: LoginUser) { | |
| const audit = <Audit>{ | |
| userId: user.userId, | |
| action: "Delete", | |
| resource: "Users", | |
| data: JSON.stringify([id]) | |
| } | |
| try { | |
| const result = db("User").update({ deleted: 1 }).where({ id }) | |
| await db("Audit").insert(<Audit>{ ...audit, status: "Success" }) | |
| return result; | |
| } | |
| catch (e) { | |
| await db("Audit").insert(<Audit>{ ...audit, status: "Error" }) | |
| throw e; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment