mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 03:39:29 +00:00
19 lines
391 B
TypeScript
19 lines
391 B
TypeScript
import Ticket from "../../models/Ticket";
|
|
import AppError from "../../errors/AppError";
|
|
|
|
const DeleteTicketService = async (id: string): Promise<Ticket> => {
|
|
const ticket = await Ticket.findOne({
|
|
where: { id }
|
|
});
|
|
|
|
if (!ticket) {
|
|
throw new AppError("No ticket found with this ID.", 404);
|
|
}
|
|
|
|
await ticket.destroy();
|
|
|
|
return ticket;
|
|
};
|
|
|
|
export default DeleteTicketService;
|