change delete ticket route to typescript

This commit is contained in:
canove
2020-09-19 21:14:25 -03:00
parent f221fef32d
commit 2bf5caadce
6 changed files with 43 additions and 37 deletions

View 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;