mirror of
https://github.com/GithubOrgProjectPiza/server.git
synced 2026-09-04 00:26:07 +02:00
Add "get all" endpoints
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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!");
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user