From b19cd97a01d646acdec30cb3843db122d65413ce Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Wed, 4 Sep 2024 14:24:30 +0200 Subject: [PATCH] router registration --- src/routes/admin/award.ts | 2 ++ src/routes/admin/communicationType.ts | 10 ++++++---- src/routes/admin/executivePosition.ts | 2 ++ src/routes/admin/index.ts | 24 ++++++++++++++++++++++++ src/routes/admin/membershipStatus.ts | 2 ++ src/routes/admin/qualification.ts | 2 ++ src/service/communicationService.ts | 3 ++- src/type/permissionTypes.ts | 4 +++- 8 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/routes/admin/award.ts b/src/routes/admin/award.ts index 84eebdf..2394153 100644 --- a/src/routes/admin/award.ts +++ b/src/routes/admin/award.ts @@ -33,3 +33,5 @@ router.patch("/:id", async (req: Request, res: Response) => { router.delete("/:id", async (req: Request, res: Response) => { await deleteAward(req, res); }); + +export default router; diff --git a/src/routes/admin/communicationType.ts b/src/routes/admin/communicationType.ts index 83fce1f..ecdc4ce 100644 --- a/src/routes/admin/communicationType.ts +++ b/src/routes/admin/communicationType.ts @@ -14,14 +14,14 @@ router.get("/", async (req: Request, res: Response) => { await getAllCommunicationTypes(req, res); }); -router.get("/:id", async (req: Request, res: Response) => { - await getCommunicationTypeById(req, res); -}); - router.get("/fields", async (req: Request, res: Response) => { await getCommunicationTypeAvailableColumns(req, res); }); +router.get("/:id", async (req: Request, res: Response) => { + await getCommunicationTypeById(req, res); +}); + router.post("/", async (req: Request, res: Response) => { await createCommunicationType(req, res); }); @@ -33,3 +33,5 @@ router.patch("/:id", async (req: Request, res: Response) => { router.delete("/:id", async (req: Request, res: Response) => { await deleteCommunicationType(req, res); }); + +export default router; diff --git a/src/routes/admin/executivePosition.ts b/src/routes/admin/executivePosition.ts index 13c15ca..c507c27 100644 --- a/src/routes/admin/executivePosition.ts +++ b/src/routes/admin/executivePosition.ts @@ -33,3 +33,5 @@ router.patch("/:id", async (req: Request, res: Response) => { router.delete("/:id", async (req: Request, res: Response) => { await deleteExecutivePosition(req, res); }); + +export default router; diff --git a/src/routes/admin/index.ts b/src/routes/admin/index.ts index 2c24b06..654c8d4 100644 --- a/src/routes/admin/index.ts +++ b/src/routes/admin/index.ts @@ -1,11 +1,35 @@ import express from "express"; import PermissionHelper from "../../helpers/permissionHelper"; +import award from "./award"; +import communicationType from "./communicationType"; +import executivePosition from "./executivePosition"; +import membershipStatus from "./membershipStatus"; +import qualification from "./qualification"; + import role from "./role"; import user from "./user"; var router = express.Router({ mergeParams: true }); +router.use("/award", PermissionHelper.passCheckMiddleware("read", "settings", "award"), award); +router.use( + "/communicationtype", + PermissionHelper.passCheckMiddleware("read", "settings", "communication"), + communicationType +); +router.use( + "/executiveposition", + PermissionHelper.passCheckMiddleware("read", "settings", "executive_position"), + executivePosition +); +router.use( + "/membershipstatus", + PermissionHelper.passCheckMiddleware("read", "settings", "membership_status"), + membershipStatus +); +router.use("/qualification", PermissionHelper.passCheckMiddleware("read", "settings", "qualification"), qualification); + router.use("/role", PermissionHelper.passCheckMiddleware("read", "user", "role"), role); router.use("/user", PermissionHelper.passCheckMiddleware("read", "user", "user"), user); diff --git a/src/routes/admin/membershipStatus.ts b/src/routes/admin/membershipStatus.ts index f62153c..3719b94 100644 --- a/src/routes/admin/membershipStatus.ts +++ b/src/routes/admin/membershipStatus.ts @@ -33,3 +33,5 @@ router.patch("/:id", async (req: Request, res: Response) => { router.delete("/:id", async (req: Request, res: Response) => { await deleteMembershipStatus(req, res); }); + +export default router; diff --git a/src/routes/admin/qualification.ts b/src/routes/admin/qualification.ts index cdbe709..a3074a4 100644 --- a/src/routes/admin/qualification.ts +++ b/src/routes/admin/qualification.ts @@ -33,3 +33,5 @@ router.patch("/:id", async (req: Request, res: Response) => { router.delete("/:id", async (req: Request, res: Response) => { await deleteQualification(req, res); }); + +export default router; diff --git a/src/service/communicationService.ts b/src/service/communicationService.ts index b30884e..441d7b9 100644 --- a/src/service/communicationService.ts +++ b/src/service/communicationService.ts @@ -28,6 +28,7 @@ export default abstract class CommunicationService { */ static getAvailableColumnsForCommunication(): Array { let metadata = dataSource.getMetadata(communication); - return metadata.columns.map((c) => c.propertyName); + let columns = metadata.columns.map((c) => c.propertyName); + return columns.filter((c) => !["id", "preffered", "type"].includes(c)); } } diff --git a/src/type/permissionTypes.ts b/src/type/permissionTypes.ts index a73000b..7e8751d 100644 --- a/src/type/permissionTypes.ts +++ b/src/type/permissionTypes.ts @@ -9,6 +9,7 @@ export type PermissionModule = | "award" | "executive_position" | "communication" + | "membership_status" | "user" | "role"; @@ -43,12 +44,13 @@ export const permissionModules: Array = [ "award", "executive_position", "communication", + "membership_status", "user", "role", ]; export const permissionTypes: Array = ["read", "create", "update", "delete"]; export const sectionsAndModules: SectionsAndModulesObject = { club: ["members", "calendar", "newsletter", "protocoll"], - settings: ["qualification", "award", "executive_position", "communication"], + settings: ["qualification", "award", "executive_position", "communication", "membership_status"], user: ["user", "role"], };