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