From 8941817594f9f01eb5bf1aaf5fe9c3b0737f5455 Mon Sep 17 00:00:00 2001 From: Hanen Alrwasheda <alrwasheda@mi.fu-berlin.de> Date: Sun, 2 Jan 2022 19:42:52 +0100 Subject: [PATCH] showAllBoats Controller --- .../controllers/boatControllers.controllers.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 server/src/controllers/boatControllers.controllers.ts diff --git a/server/src/controllers/boatControllers.controllers.ts b/server/src/controllers/boatControllers.controllers.ts new file mode 100644 index 0000000..1ed1251 --- /dev/null +++ b/server/src/controllers/boatControllers.controllers.ts @@ -0,0 +1,16 @@ +import { Request, Response } from "express"; +import Boat from "../db/models/Boat"; + +const showAllBoatsController = async (req: Request, res: Response) => { + try { + const allBoats = await Boat.findAll(); + return res.status(200).send({ success: true, allBoats }); + } catch (error) { + console.error("server error: ", error.message); + return res.status(500).json({ success: false, error: "serverError" }); + } +}; + +const boatControllers = { showAllBoatsController }; + +export default boatControllers; -- GitLab