Skip to content
Snippets Groups Projects
Commit 8444f029 authored by alrwasheda's avatar alrwasheda :speech_balloon:
Browse files

showBoatById controller

parent 2a0deb3e
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,20 @@ const showAllBoatsController = async (req: Request, res: Response) => {
}
};
const boatControllers = { showAllBoatsController };
const showBoatById = async (req: Request, res: Response) => {
try {
const givenId = req.params.id;
const boat = await Boat.findByPk(givenId);
if (boat) {
return res.status(200).json({ success: true, boat });
}
return res.status(404).json({ success: false, error: "boatIdNotFound" });
} catch (error) {
console.error("server error: ", error.message);
return res.status(500).json({ success: false, error: "serverError" });
}
};
const boatControllers = { showAllBoatsController, showBoatById };
export default boatControllers;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment