[create-pull-request] push formatted files

This commit is contained in:
Stefan-5422
2022-04-29 12:23:23 +02:00
committed by Stefan
parent ac19d9bc67
commit 4ef5989c9a
3 changed files with 6 additions and 26 deletions
+4 -19
View File
@@ -2,12 +2,7 @@ import { Prisma } from "@prisma/client";
import { PrismaClientKnownRequestError } from "@prisma/client/runtime";
import { Request, Response } from "express";
import prisma from "../lib/prisma";
import {
createInsufficientPermissionsError,
DataType,
generateError,
generateInvalidBodyError,
} from "./common";
import { createInsufficientPermissionsError, DataType, generateError, generateInvalidBodyError } from "./common";
export const getAllEvents = async (req: Request, res: Response) => {
const events = await prisma.event.findMany({
@@ -73,8 +68,7 @@ export const getEvent = async (req: Request, res: Response) => {
res.status(500).json({
type: "error",
payload: {
message:
"Unknown error occurred with your request. Check if your parameters are correct",
message: "Unknown error occurred with your request. Check if your parameters are correct",
schema: {
eventId: DataType.UUID,
},
@@ -132,10 +126,7 @@ interface DeleteEventQueryParams {
}
// requires: auth(ELEVATED)
export const deleteEvent = (
req: Request<DeleteEventQueryParams>,
res: Response
) => {
export const deleteEvent = (req: Request<DeleteEventQueryParams>, res: Response) => {
if (req.auth?.permission_level !== "ELEVATED") {
res.status(403).json(createInsufficientPermissionsError());
}
@@ -148,13 +139,7 @@ export const deleteEvent = (
return res.status(204).end();
} catch (e) {
if (e instanceof PrismaClientKnownRequestError && e.code === "P2025") {
return res
.status(404)
.json(
generateError(
`The organisation with the ID ${pid} could not be found`
)
);
return res.status(404).json(generateError(`The organisation with the ID ${pid} could not be found`));
}
throw e;