mirror of
https://github.com/detleph/server.git
synced 2026-09-04 23:45:00 +02:00
added deleteRoleSchema
This commit is contained in:
@@ -9,6 +9,7 @@ import SchemaError from "../Middleware/error/SchemaError";
|
||||
import {
|
||||
createInsufficientPermissionsError,
|
||||
DataType,
|
||||
generateError,
|
||||
generateInvalidBodyError,
|
||||
NAME_ERROR,
|
||||
validateName,
|
||||
@@ -197,6 +198,25 @@ export const updateRoleSchema = async (req: Request<{ pid: string }>, res: Respo
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteRoleSchema = async (req: Request<{ pid: string }>, res: Response) => {
|
||||
if (req.auth?.permission_level !== "ELEVATED") {
|
||||
res.status(403).json(createInsufficientPermissionsError());
|
||||
}
|
||||
|
||||
const { pid } = req.params;
|
||||
|
||||
try {
|
||||
await prisma.roleSchema.delete({ where: { pid } });
|
||||
|
||||
return res.status(204).end();
|
||||
} catch (e) {
|
||||
if (e instanceof PrismaClientKnownRequestError && e.code === "P2025") {
|
||||
return res.status(404).json(generateError(`The RoleSchema with the ID ${pid} could not be found`));
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
interface visualParams {
|
||||
schemaPid: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user