changed contacts routes to typescript

This commit is contained in:
canove
2020-09-15 19:28:06 -03:00
parent 14d90a2dd4
commit b04c0b878e
21 changed files with 536 additions and 133 deletions

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