mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-19 12:19:16 +00:00
change delete ticket route to typescript
This commit is contained in:
16
backend/src/services/TicketServices/DeleteTicketService.ts
Normal file
16
backend/src/services/TicketServices/DeleteTicketService.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import Ticket from "../../models/Ticket";
|
||||
import AppError from "../../errors/AppError";
|
||||
|
||||
const DeleteTicketService = async (id: string): Promise<void> => {
|
||||
const ticket = await Ticket.findOne({
|
||||
where: { id }
|
||||
});
|
||||
|
||||
if (!ticket) {
|
||||
throw new AppError("No ticket found with this ID.", 404);
|
||||
}
|
||||
|
||||
await ticket.destroy();
|
||||
};
|
||||
|
||||
export default DeleteTicketService;
|
||||
Reference in New Issue
Block a user