diff --git a/src/controller/orders.controller.ts b/src/controller/orders.controller.ts index 0bfebe0..9fa3eba 100644 --- a/src/controller/orders.controller.ts +++ b/src/controller/orders.controller.ts @@ -87,3 +87,9 @@ export const getOrder = async (req: Request, res: Response) => { res.status(HttpStatusCodes.OK).json(order); }; + +export const getOrders = async (_req: Request, res: Response) => { + const orders = await prisma.order.findMany(); + + res.status(HttpStatusCodes.OK).json(orders); +}; diff --git a/src/controller/organisations.controller.ts b/src/controller/organisations.controller.ts index d0b0030..cc2184f 100644 --- a/src/controller/organisations.controller.ts +++ b/src/controller/organisations.controller.ts @@ -85,3 +85,9 @@ export const getOrganization = async (req: Request, res: Response) => { res.status(HttpStatusCodes.OK).json(organization); }; + +export const getOrganizations = async (_req: Request, res: Response) => { + const organizations = await prisma.organization.findMany(); + + res.status(HttpStatusCodes.OK).json(organizations); +}; diff --git a/src/controller/pizzas.controller.ts b/src/controller/pizzas.controller.ts index a96ea14..8b392f8 100644 --- a/src/controller/pizzas.controller.ts +++ b/src/controller/pizzas.controller.ts @@ -96,3 +96,9 @@ export const getPizza = async (req: Request, res: Response) => { res.status(HttpStatusCodes.OK).json(pizza); }; + +export const getPizzas = async (_req: Request, res: Response) => { + const pizzas = await prisma.pizza.findMany(); + + res.status(HttpStatusCodes.OK).json(pizzas); +}; diff --git a/src/controller/restaurants.controller.ts b/src/controller/restaurants.controller.ts index 68b2a03..abec94b 100644 --- a/src/controller/restaurants.controller.ts +++ b/src/controller/restaurants.controller.ts @@ -85,3 +85,9 @@ export const getRestaurant = async (req: Request, res: Response) => { res.status(HttpStatusCodes.OK).json(restaurant); }; + +export const getRestaurants = async (_req: Request, res: Response) => { + const restaurants = await prisma.restaurant.findMany(); + + res.status(HttpStatusCodes.OK).json(restaurants); +} diff --git a/src/index.ts b/src/index.ts index 3d5f077..76322d3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,7 +13,7 @@ app.use("/pizza", pizzasRoutes); app.use("/restaurant", restaurantsRoutes); async function main() { - app.get("/", (req, res) => { + app.get("/", (_req, res) => { res.send("Hello World!"); }); diff --git a/src/routes/orders.route.ts b/src/routes/orders.route.ts index f10a514..c7b618f 100644 --- a/src/routes/orders.route.ts +++ b/src/routes/orders.route.ts @@ -1,8 +1,9 @@ import express from "express"; -import { addOrder, deleteOrder, getOrder, updateOrder } from "../controller/orders.controller"; +import { addOrder, deleteOrder, getOrder, updateOrder, getOrders } from "../controller/orders.controller"; const router = express.Router(); +router.get("/", getOrders); router.get("/:id", getOrder); router.post("/", addOrder); router.put("/:id", updateOrder); diff --git a/src/routes/organisations.route.ts b/src/routes/organisations.route.ts index de68ac0..9a44d25 100644 --- a/src/routes/organisations.route.ts +++ b/src/routes/organisations.route.ts @@ -1,5 +1,6 @@ import express from "express"; import { + getOrganizations, addOrganization, deleteOrganization, getOrganization, @@ -8,6 +9,7 @@ import { const router = express.Router(); +router.get("/organizations", getOrganizations); router.get("/:id", getOrganization); router.post("/", addOrganization); router.put("/:id", updateOrganization); diff --git a/src/routes/pizzas.route.ts b/src/routes/pizzas.route.ts index fed4038..4fec840 100644 --- a/src/routes/pizzas.route.ts +++ b/src/routes/pizzas.route.ts @@ -1,8 +1,9 @@ import express from "express"; -import { addPizza, deletePizza, getPizza, updatePizza } from "../controller/pizzas.controller"; +import { getPizzas, addPizza, deletePizza, getPizza, updatePizza } from "../controller/pizzas.controller"; const router = express.Router(); +router.get("/", getPizzas); router.get("/:id", getPizza); router.post("/", addPizza); router.put("/:id", updatePizza); diff --git a/src/routes/restaurants.route.ts b/src/routes/restaurants.route.ts index 077662b..a2f98fd 100644 --- a/src/routes/restaurants.route.ts +++ b/src/routes/restaurants.route.ts @@ -1,8 +1,15 @@ import express from "express"; -import { addRestaurant, deleteRestaurant, getRestaurant, updateRestaurant } from "../controller/restaurants.controller"; +import { + getRestaurants, + addRestaurant, + deleteRestaurant, + getRestaurant, + updateRestaurant, +} from "../controller/restaurants.controller"; const router = express.Router(); +router.get("/restaurants", getRestaurants); router.get("/:id", getRestaurant); router.post("/", addRestaurant); router.put("/:id", updateRestaurant);