mirror of
https://github.com/GithubOrgProjectPiza/server.git
synced 2026-09-04 08:36:10 +02:00
Correct formatting
This commit is contained in:
@@ -15,8 +15,8 @@ export const addOrganization = async (req: Request, res: Response) => {
|
|||||||
const organization = await prisma.organization.create({
|
const organization = await prisma.organization.create({
|
||||||
data: {
|
data: {
|
||||||
name: req.body.name,
|
name: req.body.name,
|
||||||
domain: req.body.domain
|
domain: req.body.domain,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
res.status(HttpStatusCodes.CREATED).json(organization);
|
res.status(HttpStatusCodes.CREATED).json(organization);
|
||||||
@@ -43,7 +43,7 @@ export const updateOrganization = async (req: Request, res: Response) => {
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
name: req.body.name,
|
name: req.body.name,
|
||||||
domain: req.body.domain
|
domain: req.body.domain,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ export const deleteOrganization = async (req: Request, res: Response) => {
|
|||||||
await prisma.organization.delete({
|
await prisma.organization.delete({
|
||||||
where: {
|
where: {
|
||||||
id: id,
|
id: id,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
res.status(HttpStatusCodes.NO_CONTENT).json();
|
res.status(HttpStatusCodes.NO_CONTENT).json();
|
||||||
@@ -80,7 +80,7 @@ export const getOrganization = async (req: Request, res: Response) => {
|
|||||||
const organization = await prisma.restaurant.findUnique({
|
const organization = await prisma.restaurant.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: id,
|
id: id,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
res.status(HttpStatusCodes.OK).json(organization);
|
res.status(HttpStatusCodes.OK).json(organization);
|
||||||
|
|||||||
@@ -4,11 +4,15 @@ import { DataType } from "../datatypes";
|
|||||||
import prisma from "../lib/prisma.lib";
|
import prisma from "../lib/prisma.lib";
|
||||||
|
|
||||||
export const addPizza = async (req: Request, res: Response) => {
|
export const addPizza = async (req: Request, res: Response) => {
|
||||||
if (typeof req.body.name !== "string" || typeof req.body.description !== "string" || typeof req.body.restaurantId !== "number") {
|
if (
|
||||||
|
typeof req.body.name !== "string" ||
|
||||||
|
typeof req.body.description !== "string" ||
|
||||||
|
typeof req.body.restaurantId !== "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,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -17,7 +21,7 @@ export const addPizza = async (req: Request, res: Response) => {
|
|||||||
data: {
|
data: {
|
||||||
name: req.body.name,
|
name: req.body.name,
|
||||||
description: req.body.description,
|
description: req.body.description,
|
||||||
restaurantId: req.body.restaurantId
|
restaurantId: req.body.restaurantId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -31,11 +35,15 @@ export const updatePizza = async (req: Request, res: Response) => {
|
|||||||
res.status(HttpStatusCodes.BAD_REQUEST).json({
|
res.status(HttpStatusCodes.BAD_REQUEST).json({
|
||||||
id: DataType.NUMBER,
|
id: DataType.NUMBER,
|
||||||
});
|
});
|
||||||
} else if (typeof req.body.name !== "string" || typeof req.body.description !== "string" || typeof req.body.restaurantId !== "number") {
|
} else if (
|
||||||
|
typeof req.body.name !== "string" ||
|
||||||
|
typeof req.body.description !== "string" ||
|
||||||
|
typeof req.body.restaurantId !== "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,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -65,7 +73,7 @@ export const deletePizza = async (req: Request, res: Response) => {
|
|||||||
await prisma.pizza.delete({
|
await prisma.pizza.delete({
|
||||||
where: {
|
where: {
|
||||||
id: id,
|
id: id,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
res.status(HttpStatusCodes.NO_CONTENT).json();
|
res.status(HttpStatusCodes.NO_CONTENT).json();
|
||||||
@@ -82,8 +90,8 @@ export const getPizza = async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
const pizza = await prisma.pizza.findUnique({
|
const pizza = await prisma.pizza.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: id
|
id: id,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
res.status(HttpStatusCodes.OK).json(pizza);
|
res.status(HttpStatusCodes.OK).json(pizza);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export const deleteRestaurant = async (req: Request, res: Response) => {
|
|||||||
await prisma.restaurant.delete({
|
await prisma.restaurant.delete({
|
||||||
where: {
|
where: {
|
||||||
id: id,
|
id: id,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
res.status(HttpStatusCodes.NO_CONTENT).json();
|
res.status(HttpStatusCodes.NO_CONTENT).json();
|
||||||
@@ -79,8 +79,8 @@ export const getRestaurant = async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
const restaurant = await prisma.restaurant.findUnique({
|
const restaurant = await prisma.restaurant.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: id
|
id: id,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
res.status(HttpStatusCodes.OK).json(restaurant);
|
res.status(HttpStatusCodes.OK).json(restaurant);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
export const sayHello = async (request: Request, response: Response) =>
|
export const sayHello = async (request: Request, response: Response) => {
|
||||||
{
|
response.status(200).send("Hello!");
|
||||||
response.status(200).send("Hello!");
|
};
|
||||||
}
|
|
||||||
|
|||||||
+1
-1
@@ -24,4 +24,4 @@ async function main() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ let prisma: PrismaClient;
|
|||||||
|
|
||||||
prisma = new PrismaClient();
|
prisma = new PrismaClient();
|
||||||
|
|
||||||
export default prisma;
|
export default prisma;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import express, { Request, Response } from "express";
|
import express from "express";
|
||||||
import { addOrder, deleteOrder, getOrder, updateOrder } from "../controller/orders.controller";
|
import { addOrder, deleteOrder, getOrder, updateOrder } from "../controller/orders.controller";
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import express, { Request, Response } from "express";
|
import express from "express";
|
||||||
import { addOrganization, deleteOrganization, getOrganization, updateOrganization } from "../controller/organisations.controller";
|
import {
|
||||||
|
addOrganization,
|
||||||
|
deleteOrganization,
|
||||||
|
getOrganization,
|
||||||
|
updateOrganization,
|
||||||
|
} from "../controller/organisations.controller";
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import express, { Request, Response } from "express";
|
import express from "express";
|
||||||
import { addPizza, deletePizza, getPizza, updatePizza } from "..///controller/pizzas.controller";
|
import { addPizza, deletePizza, getPizza, updatePizza } from "../controller/pizzas.controller";
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import express, { Request, Response } from "express";
|
import express from "express";
|
||||||
import { addRestaurant, deleteRestaurant, getRestaurant, updateRestaurant } from "../controller/restaurants.controller";
|
import { addRestaurant, deleteRestaurant, getRestaurant, updateRestaurant } from "../controller/restaurants.controller";
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import express, { Request, Response } from "express";
|
import express from "express";
|
||||||
import { sayHello } from "../controller/testcontroller.controller";
|
import { sayHello } from "../controller/testcontroller.controller";
|
||||||
|
|
||||||
export const router = express.Router();
|
export const router = express.Router();
|
||||||
|
|||||||
Reference in New Issue
Block a user