Skip to content
Snippets Groups Projects
Commit bbd21e2f authored by Alexander Rudolph's avatar Alexander Rudolph
Browse files

adapt boat route for the right error codes

parent f5fa8077
No related branches found
No related tags found
No related merge requests found
...@@ -158,6 +158,9 @@ const getBoatOverview = async (req: Request, res: Response) => { ...@@ -158,6 +158,9 @@ const getBoatOverview = async (req: Request, res: Response) => {
}; };
const lock = async (req: Request, res: Response) => { const lock = async (req: Request, res: Response) => {
if (!await Boat.findByPk(req.params.id)) {
return res.status(404).json({ success: false, error: "boatIdNotFound" });
}
await Boat.update({ await Boat.update({
status: 1, status: 1,
}, { }, {
...@@ -171,6 +174,9 @@ const lock = async (req: Request, res: Response) => { ...@@ -171,6 +174,9 @@ const lock = async (req: Request, res: Response) => {
}); });
}; };
const unlock = async (req: Request, res: Response) => { const unlock = async (req: Request, res: Response) => {
if (!await Boat.findByPk(req.params.id)) {
return res.status(404).json({ success: false, error: "boatIdNotFound" });
}
await Boat.update({ await Boat.update({
status: 0, status: 0,
}, { }, {
......
...@@ -37,9 +37,9 @@ boatsRouter.post( ...@@ -37,9 +37,9 @@ boatsRouter.post(
//update boat by id //update boat by id
boatsRouter.patch( boatsRouter.patch(
"/api/boat/:id/", "/api/boat/:id/",
body("name").not().isEmpty(), body("name").if(body("name").exists()).not().isEmpty(),
body("boattype").not().isEmpty(), body("boattype").if(body("boattype").exists()).not().isEmpty(),
body("status").not().isEmpty(), body("status").if(body("status").exists()).not().isEmpty(),
handleValidationResult, handleValidationResult,
validateToken, validateToken,
isCoord, isCoord,
......
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