Merge pull request #60 from detleph/create-pull-request/patch

Reformat files using prettier
This commit is contained in:
Stephan
2022-05-30 21:59:20 +02:00
committed by GitHub
4 changed files with 84 additions and 67 deletions
+5 -2
View File
@@ -159,12 +159,15 @@ export const updateEvent = async (req: Request<{ pid: string }>, res: Response)
if (result.success === false) {
return res.status(400).json(
generateInvalidBodyError({
generateInvalidBodyError(
{
name: DataType.STRING,
date: DataType.DATETIME,
briefDescription: DataType.STRING,
["fullDescription?"]: DataType.STRING,
}, result.error)
},
result.error
)
);
}
+13 -7
View File
@@ -5,7 +5,14 @@ import { z } from "zod";
import prisma from "../lib/prisma";
import { requireResponsibleForGroup } from "../Middleware/auth/auth";
import NotFoundError from "../Middleware/error/NotFoundError";
import { createInsufficientPermissionsError, DataType, generateError, generateInvalidBodyError, genericError, handleCreateByName } from "./common";
import {
createInsufficientPermissionsError,
DataType,
generateError,
generateInvalidBodyError,
genericError,
handleCreateByName,
} from "./common";
const updateGroupBody = z
.object({
@@ -131,7 +138,7 @@ export const createGroup = async (req: Request<{ organisationPid: string }, {},
export const updateGroup = async (req: Request<{ pid: string }>, res: Response) => {
const result = updateGroupBody.safeParse(req.body);
if(result.success === false){
if (result.success === false) {
return res.status(400).json(
generateInvalidBodyError(
{
@@ -147,7 +154,7 @@ export const updateGroup = async (req: Request<{ pid: string }>, res: Response)
const body = result.data;
const { pid } = req.params;
requireResponsibleForGroup(req.auth, pid)
requireResponsibleForGroup(req.auth, pid);
try {
const group = await prisma.group.update({
@@ -164,15 +171,14 @@ export const updateGroup = async (req: Request<{ pid: string }>, res: Response)
type: "success",
payload: { group },
});
} catch (e) {
if (e instanceof Prisma.PrismaClientKnownRequestError && e.code === "P2025") {
throw new NotFoundError("group", pid)
throw new NotFoundError("group", pid);
}
throw e;
}
}
};
interface DeleteGroupQueryParams {
pid: string;
@@ -191,7 +197,7 @@ export const deleteGroup = async (req: Request<DeleteGroupQueryParams>, res: Res
return res.status(204).end();
} catch (e) {
if (e instanceof PrismaClientKnownRequestError && e.code === "P2025") {
throw new NotFoundError("group", pid)
throw new NotFoundError("group", pid);
}
throw e;
+18 -13
View File
@@ -102,7 +102,7 @@ export const updateRoleScore = async (req: Request<{ pid: string }, {}, { score:
const { score } = req.body;
if(typeof score !== "string"){
if (typeof score !== "string") {
res.status(400).json(generateInvalidBodyError({ score: DataType.STRING }));
}
@@ -115,20 +115,26 @@ export const updateRoleScore = async (req: Request<{ pid: string }, {}, { score:
select: {
pid: true,
score: true,
schema: { select: {
schema: {
select: {
pid: true,
name: true,
} },
participant: { select: {
},
},
participant: {
select: {
pid: true,
firstName: true,
lastName: true,
} },
team: { select: {
},
},
team: {
select: {
pid: true,
name: true,
}}
}
},
},
},
});
res.status(200).json({
@@ -137,18 +143,17 @@ export const updateRoleScore = async (req: Request<{ pid: string }, {}, { score:
role,
},
});
} catch (e) {
if (e instanceof Prisma.PrismaClientKnownRequestError && e.code === "P2025") {
throw new NotFoundError("role", pid)
throw new NotFoundError("role", pid);
}
throw e;
}
}
};
export async function deleteRolesFromTeam(teamPid: string){
export async function deleteRolesFromTeam(teamPid: string) {
await prisma.role.deleteMany({
where: { team: { pid: teamPid, } }
where: { team: { pid: teamPid } },
});
}
+8 -5
View File
@@ -145,14 +145,17 @@ export const updateRoleSchema = async (req: Request<{ pid: string }>, res: Respo
if (result.success === false) {
return res.status(400).json(
generateInvalidBodyError({
generateInvalidBodyError(
{
name: DataType.STRING,
schema: DataType.RESULT_SCHEMA,
}, result.error)
},
result.error
)
);
}
const {name, schema} = result.data;
const { name, schema } = result.data;
const validatedSchema = parseSchema(schema);
@@ -172,7 +175,7 @@ export const updateRoleSchema = async (req: Request<{ pid: string }>, res: Respo
});
} catch (e) {
if (e instanceof Prisma.PrismaClientKnownRequestError && e.code === "P2025") {
throw new NotFoundError("roleSchema", pid)
throw new NotFoundError("roleSchema", pid);
}
throw e;
@@ -197,7 +200,7 @@ export const deleteRoleSchema = async (req: Request<{ pid: string }>, res: Respo
throw e;
}
}
};
interface visualParams {
schemaPid: string;