Files
whaticket-community/backend/src/services/ContactServices/ShowContactService.ts
2020-09-15 19:28:06 -03:00

18 lines
412 B
TypeScript

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;