From 22d7865065bb1d417982d47c1fd42b5690def9dd Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Sat, 2 Apr 2022 18:51:49 +0200 Subject: [PATCH] Correct formatting --- src/controller/organisations.controller.ts | 10 ++++----- src/controller/pizzas.controller.ts | 24 ++++++++++++++------- src/controller/restaurants.controller.ts | 6 +++--- src/controller/testcontroller.controller.ts | 7 +++--- src/index.ts | 2 +- src/lib/prisma.lib.ts | 2 +- src/routes/orders.route.ts | 2 +- src/routes/organisations.route.ts | 9 ++++++-- src/routes/pizzas.route.ts | 4 ++-- src/routes/restaurants.route.ts | 2 +- src/routes/testrouter.route.ts | 2 +- 11 files changed, 41 insertions(+), 29 deletions(-) diff --git a/src/controller/organisations.controller.ts b/src/controller/organisations.controller.ts index 655adb4..4af0f52 100644 --- a/src/controller/organisations.controller.ts +++ b/src/controller/organisations.controller.ts @@ -15,8 +15,8 @@ export const addOrganization = async (req: Request, res: Response) => { const organization = await prisma.organization.create({ data: { name: req.body.name, - domain: req.body.domain - } + domain: req.body.domain, + }, }); res.status(HttpStatusCodes.CREATED).json(organization); @@ -43,7 +43,7 @@ export const updateOrganization = async (req: Request, res: Response) => { }, data: { 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({ where: { id: id, - } + }, }); res.status(HttpStatusCodes.NO_CONTENT).json(); @@ -80,7 +80,7 @@ export const getOrganization = async (req: Request, res: Response) => { const organization = await prisma.restaurant.findUnique({ where: { id: id, - } + }, }); res.status(HttpStatusCodes.OK).json(organization); diff --git a/src/controller/pizzas.controller.ts b/src/controller/pizzas.controller.ts index ac6a490..a96ea14 100644 --- a/src/controller/pizzas.controller.ts +++ b/src/controller/pizzas.controller.ts @@ -4,11 +4,15 @@ import { DataType } from "../datatypes"; import prisma from "../lib/prisma.lib"; 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({ name: DataType.STRING, description: DataType.STRING, - restaurantId: DataType.NUMBER + restaurantId: DataType.NUMBER, }); return; } @@ -17,7 +21,7 @@ export const addPizza = async (req: Request, res: Response) => { data: { name: req.body.name, 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({ 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({ name: DataType.STRING, description: DataType.STRING, - restaurantId: DataType.NUMBER + restaurantId: DataType.NUMBER, }); return; } @@ -65,7 +73,7 @@ export const deletePizza = async (req: Request, res: Response) => { await prisma.pizza.delete({ where: { id: id, - } + }, }); res.status(HttpStatusCodes.NO_CONTENT).json(); @@ -82,8 +90,8 @@ export const getPizza = async (req: Request, res: Response) => { const pizza = await prisma.pizza.findUnique({ where: { - id: id - } + id: id, + }, }); res.status(HttpStatusCodes.OK).json(pizza); diff --git a/src/controller/restaurants.controller.ts b/src/controller/restaurants.controller.ts index 7113acc..68b2a03 100644 --- a/src/controller/restaurants.controller.ts +++ b/src/controller/restaurants.controller.ts @@ -62,7 +62,7 @@ export const deleteRestaurant = async (req: Request, res: Response) => { await prisma.restaurant.delete({ where: { id: id, - } + }, }); res.status(HttpStatusCodes.NO_CONTENT).json(); @@ -79,8 +79,8 @@ export const getRestaurant = async (req: Request, res: Response) => { const restaurant = await prisma.restaurant.findUnique({ where: { - id: id - } + id: id, + }, }); res.status(HttpStatusCodes.OK).json(restaurant); diff --git a/src/controller/testcontroller.controller.ts b/src/controller/testcontroller.controller.ts index 25f420a..cb7ef10 100644 --- a/src/controller/testcontroller.controller.ts +++ b/src/controller/testcontroller.controller.ts @@ -1,6 +1,5 @@ import { Request, Response } from "express"; -export const sayHello = async (request: Request, response: Response) => -{ - response.status(200).send("Hello!"); -} +export const sayHello = async (request: Request, response: Response) => { + response.status(200).send("Hello!"); +}; diff --git a/src/index.ts b/src/index.ts index f64ec17..6423178 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,4 +24,4 @@ async function main() { }); } -main(); \ No newline at end of file +main(); diff --git a/src/lib/prisma.lib.ts b/src/lib/prisma.lib.ts index e88f688..431bfc0 100644 --- a/src/lib/prisma.lib.ts +++ b/src/lib/prisma.lib.ts @@ -5,4 +5,4 @@ let prisma: PrismaClient; prisma = new PrismaClient(); -export default prisma; \ No newline at end of file +export default prisma; diff --git a/src/routes/orders.route.ts b/src/routes/orders.route.ts index 68e2978..f10a514 100644 --- a/src/routes/orders.route.ts +++ b/src/routes/orders.route.ts @@ -1,4 +1,4 @@ -import express, { Request, Response } from "express"; +import express from "express"; import { addOrder, deleteOrder, getOrder, updateOrder } from "../controller/orders.controller"; const router = express.Router(); diff --git a/src/routes/organisations.route.ts b/src/routes/organisations.route.ts index 060cb47..de68ac0 100644 --- a/src/routes/organisations.route.ts +++ b/src/routes/organisations.route.ts @@ -1,5 +1,10 @@ -import express, { Request, Response } from "express"; -import { addOrganization, deleteOrganization, getOrganization, updateOrganization } from "../controller/organisations.controller"; +import express from "express"; +import { + addOrganization, + deleteOrganization, + getOrganization, + updateOrganization, +} from "../controller/organisations.controller"; const router = express.Router(); diff --git a/src/routes/pizzas.route.ts b/src/routes/pizzas.route.ts index c439a4f..fed4038 100644 --- a/src/routes/pizzas.route.ts +++ b/src/routes/pizzas.route.ts @@ -1,5 +1,5 @@ -import express, { Request, Response } from "express"; -import { addPizza, deletePizza, getPizza, updatePizza } from "..///controller/pizzas.controller"; +import express from "express"; +import { addPizza, deletePizza, getPizza, updatePizza } from "../controller/pizzas.controller"; const router = express.Router(); diff --git a/src/routes/restaurants.route.ts b/src/routes/restaurants.route.ts index d9e29ee..077662b 100644 --- a/src/routes/restaurants.route.ts +++ b/src/routes/restaurants.route.ts @@ -1,4 +1,4 @@ -import express, { Request, Response } from "express"; +import express from "express"; import { addRestaurant, deleteRestaurant, getRestaurant, updateRestaurant } from "../controller/restaurants.controller"; const router = express.Router(); diff --git a/src/routes/testrouter.route.ts b/src/routes/testrouter.route.ts index 40fc0dc..721a764 100644 --- a/src/routes/testrouter.route.ts +++ b/src/routes/testrouter.route.ts @@ -1,4 +1,4 @@ -import express, { Request, Response } from "express"; +import express from "express"; import { sayHello } from "../controller/testcontroller.controller"; export const router = express.Router();