diff --git a/server/notes b/server/notes deleted file mode 100644 index 3c0dbd2093252cf3696a25fe100f1c6fd8bfef95..0000000000000000000000000000000000000000 --- a/server/notes +++ /dev/null @@ -1,42 +0,0 @@ -Boot: -minP,maxP (ja) - -BootsType: -id, name (ja) -- color (donnerstag, im Frontend random oder in der DB festlegen?) - -BootHatBootType: -bootId,bootTypeId (primaryKeys) (ja) - -checkIn: --Token(GD von Kunde) oder Sicherheitsfrage ( donnerstag ) --müssen alle Boote in der Bootshalle ausgetragen werden könne -(ja) --Art: wie wurde gebucht (ja) --Datum --Ziel: optional? --numP (Alle Personen inkl. Verantwortliche) --email: von der buchenden Person --zurückgegeben: true/false --Anmerkung: vor oder auch nach Fahrt - - -changes in Endpoints: -sequelize: init boatHasBoatType table() -createLogEntry: comparison -boat: created connection in boatHasBoatType table -boattype: show boatType by give boatId must be written again. - - - ------------------ -19.01: -DB Sport BoatHasSport -BoatController -BoatRoutes : (fehlt) überpüfen ob SportsArrayElements UUID sind!!!! -index.ts (init-methods) - - - - - diff --git a/server/src/controllers/boat.controllers.ts b/server/src/controllers/boat.controllers.ts index 17a578a14663aa8bb99f12d2f57c21d12d863b52..951ae105a12d0d79adb0582a975b19899676d8f0 100644 --- a/server/src/controllers/boat.controllers.ts +++ b/server/src/controllers/boat.controllers.ts @@ -24,31 +24,26 @@ const createBoat = async (req: Request, res: Response) => { } //check if name of boat already exists - if (!(newBoatInput.name === undefined)) { - const checkBoatName = await Boat.findOne({ - where: { - name: newBoatInput.name, - }, - }); - if (!(checkBoatName === null)) { - return res - .status(400) - .json({ success: false, error: "boatNameAlreadyExists" }); - } + const checkBoatName = await Boat.findOne({ + where: { + name: newBoatInput.name, + }, + }); + + if (!(checkBoatName === null)) { + return res + .status(400) + .json({ success: false, error: "boatNameAlreadyExists" }); } //check if minP is bigger than maxP => error - if ( - !(newBoatInput.minP === undefined) && - !(newBoatInput.maxP === undefined) - ) { - if (newBoatInput.minP > newBoatInput.maxP) { - return res.status(409).json({ - success: false, - error: "maximumNumberOfSeatsMustBeBiggerOrEqualMinimalNumberOfSeats", - }); - } + + if (newBoatInput.minP > newBoatInput.maxP) { + return res.status(409).json({ + success: false, + error: "maximumNumberOfSeatsMustBeBiggerOrEqualMinimalNumberOfSeats", + }); } //check if given sport-ids can be found @@ -79,10 +74,7 @@ const createBoat = async (req: Request, res: Response) => { //if there is a sport, which isn't in the database, we return an array with the names of the missing sports if (check === false) { - return res.status(404).json({ - success: false, - error: "The SportIDs: " + listIfNotFound + " cannotBeFound", - }); + return res.status(404).json({ success: false, sports: listIfNotFound }); } //create the boat @@ -335,9 +327,7 @@ const updateBoatById = async (req: Request, res: Response) => { //if the updated-to-be sportid(sportids) doesn't exist if (check === false) { - return res - .status(404) - .json({ success: false, sports: listIfNotFound }); + return res.status(404).json({ success: false, sports: listIfNotFound }); } //if sports Array is with valid id's, assign them to boat; create entry (boatid, each id of given sportIds) inf BoatHasSport table for (let i = 0; i < listIfFound.length; i++) { diff --git a/server/src/controllers/sport.controllers.ts b/server/src/controllers/sport.controllers.ts index a148fa66ebc627eb526527509b955c857addddc2..af7a12c6533273473c722db40be013b3b1df9909 100644 --- a/server/src/controllers/sport.controllers.ts +++ b/server/src/controllers/sport.controllers.ts @@ -242,36 +242,12 @@ const showSportByBoatId = async (req: Request, res: Response) => { } }; -// is this controller needed? -const showSportBySportId = async (req: Request, res: Response) => { - try { - if (!(res.locals.user.role === "coordinator")) { - return res - .status(403) - .json({ success: false, error: "MustBeCoordinator" }); - } - const givenId = req.params.id; - const sport = await Sport.findByPk(givenId); - if (sport) { - return res.status(200).json({ - success: true, - result: { id: givenId, name: sport.name, color: sport.color }, - }); - } - return res.status(404).json({ success: false, error: "sportIdNotFound" }); - } catch (error) { - console.error("server error: ", error.message); - return res.status(500).json({ success: false, error: "serverError" }); - } -}; - const sportControllers = { createSportController, showAllSports, deleteSportById, updateSportById, showSportByBoatId, - showSportBySportId, }; export default sportControllers; diff --git a/server/src/routes/createLogEntry.routes.ts b/server/src/routes/createLogEntry.routes.ts index 4b23800335aa9ce837d5ba3bca95c82d59a12b1d..56ba2ebb6dc8394a13857669781250c95600aaeb 100644 --- a/server/src/routes/createLogEntry.routes.ts +++ b/server/src/routes/createLogEntry.routes.ts @@ -16,7 +16,7 @@ entryRouter.post( body("fullNameOfResponsibleClient").not().isEmpty(), body("boatId").isUUID(), body("additionalClients").if(body("additionalClients").exists()).isArray(), - body("numP").isInt(), + body("numP").isInt(), //number of the total participants (fullNameOfResponsibleClient + additionalClients) body("note").if(body("note").exists()).isString(), handleValidationResult, createLogEntryController diff --git a/server/src/routes/sport.routes.ts b/server/src/routes/sport.routes.ts index e79d88f8b4442750245a86eb12773b57d5b52ee0..4d285325669dfcda8f731f6c67ab8a2f3c054fc9 100644 --- a/server/src/routes/sport.routes.ts +++ b/server/src/routes/sport.routes.ts @@ -7,11 +7,7 @@ import validateToken from "../middleware/validateToken"; const sportRouter = Router(); //show all sports -sportRouter.get( - "/api/sport/", - validateToken, - sportControllers.showAllSports -); +sportRouter.get("/api/sport/", validateToken, sportControllers.showAllSports); //create a sport sportRouter.post( @@ -27,7 +23,7 @@ sportRouter.post( sportRouter.delete( "/api/sport/:id", validateToken, - sportControllers.deleteSportById, + sportControllers.deleteSportById ); //update a sport @@ -47,16 +43,4 @@ sportRouter.get( sportControllers.showSportByBoatId ); -/* - -//maybe this route is not needed -//show specific sport by sport id -sportRouter.get( - "/api/sport/id/:id/", - validateToken, - sportControllers.showSportBySportId -) - -*/ - -export default sportRouter; \ No newline at end of file +export default sportRouter;