mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-21 05:09:18 +00:00
changed contacts routes to typescript
This commit is contained in:
16
backend/src/services/ContactServices/DeleteContactService.ts
Normal file
16
backend/src/services/ContactServices/DeleteContactService.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import Contact from "../../models/Contact";
|
||||
import AppError from "../../errors/AppError";
|
||||
|
||||
const DeleteContactService = async (id: string): Promise<void> => {
|
||||
const contact = await Contact.findOne({
|
||||
where: { id }
|
||||
});
|
||||
|
||||
if (!contact) {
|
||||
throw new AppError("No contact found with this ID.", 404);
|
||||
}
|
||||
|
||||
await contact.destroy();
|
||||
};
|
||||
|
||||
export default DeleteContactService;
|
||||
Reference in New Issue
Block a user