mirror of
https://github.com/GithubOrgProjectPiza/server.git
synced 2026-09-05 23:33:58 +02:00
Merge pull request #8 from GithubOrgProjectPiza/routes-implementation
Routes implementation
This commit is contained in:
@@ -7,12 +7,14 @@ export const addPizza = async (req: Request, res: Response) => {
|
|||||||
if (
|
if (
|
||||||
typeof req.body.name !== "string" ||
|
typeof req.body.name !== "string" ||
|
||||||
typeof req.body.description !== "string" ||
|
typeof req.body.description !== "string" ||
|
||||||
typeof req.body.restaurantId !== "number"
|
typeof req.body.restaurantId !== "number" ||
|
||||||
|
typeof req.body.price !== "number"
|
||||||
) {
|
) {
|
||||||
res.status(HttpStatusCodes.BAD_REQUEST).json({
|
res.status(HttpStatusCodes.BAD_REQUEST).json({
|
||||||
name: DataType.STRING,
|
name: DataType.STRING,
|
||||||
description: DataType.STRING,
|
description: DataType.STRING,
|
||||||
restaurantId: DataType.NUMBER,
|
restaurantId: DataType.NUMBER,
|
||||||
|
price: DataType.NUMBER
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -22,6 +24,7 @@ export const addPizza = async (req: Request, res: Response) => {
|
|||||||
name: req.body.name,
|
name: req.body.name,
|
||||||
description: req.body.description,
|
description: req.body.description,
|
||||||
restaurantId: req.body.restaurantId,
|
restaurantId: req.body.restaurantId,
|
||||||
|
price: req.body.price
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -38,12 +41,14 @@ export const updatePizza = async (req: Request, res: Response) => {
|
|||||||
} else if (
|
} else if (
|
||||||
typeof req.body.name !== "string" ||
|
typeof req.body.name !== "string" ||
|
||||||
typeof req.body.description !== "string" ||
|
typeof req.body.description !== "string" ||
|
||||||
typeof req.body.restaurantId !== "number"
|
typeof req.body.restaurantId !== "number" ||
|
||||||
|
typeof req.body.price !== "number"
|
||||||
) {
|
) {
|
||||||
res.status(HttpStatusCodes.BAD_REQUEST).json({
|
res.status(HttpStatusCodes.BAD_REQUEST).json({
|
||||||
name: DataType.STRING,
|
name: DataType.STRING,
|
||||||
description: DataType.STRING,
|
description: DataType.STRING,
|
||||||
restaurantId: DataType.NUMBER,
|
restaurantId: DataType.NUMBER,
|
||||||
|
price: DataType.NUMBER
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -55,6 +60,7 @@ export const updatePizza = async (req: Request, res: Response) => {
|
|||||||
data: {
|
data: {
|
||||||
name: req.body.name,
|
name: req.body.name,
|
||||||
description: req.body.description,
|
description: req.body.description,
|
||||||
|
price: req.body.price
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user