mirror of
https://github.com/detleph/server.git
synced 2026-09-04 00:26:03 +02:00
Merge pull request #60 from detleph/create-pull-request/patch
Reformat files using prettier
This commit is contained in:
@@ -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
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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({
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
await prisma.role.deleteMany({
|
||||
where: { team: { pid: teamPid, } }
|
||||
where: { team: { pid: teamPid } },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -145,10 +145,13 @@ 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
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user