diff --git a/src/routes/admin/calendar.ts b/src/routes/admin/calendar.ts index e6f7181..7503dee 100644 --- a/src/routes/admin/calendar.ts +++ b/src/routes/admin/calendar.ts @@ -15,84 +15,36 @@ import PermissionHelper from "../../helpers/permissionHelper"; var router = express.Router({ mergeParams: true }); -router.get( - "/items", - PermissionHelper.passCheckMiddleware("read", "club", "calendar"), - async (req: Request, res: Response) => { - await getAllCalendarItems(req, res); - } -); +router.get("/", async (req: Request, res: Response) => { + await getAllCalendarItems(req, res); +}); -router.get( - "/item/:id", - PermissionHelper.passCheckMiddleware("read", "club", "calendar"), - async (req: Request, res: Response) => { - await getCalendarItemById(req, res); - } -); - -router.get( - "/types", - PermissionHelper.passCheckMiddleware("read", "settings", "calendar_type"), - async (req: Request, res: Response) => { - await getAllCalendarTypes(req, res); - } -); - -router.get( - "/type/:id", - PermissionHelper.passCheckMiddleware("read", "settings", "calendar_type"), - async (req: Request, res: Response) => { - await getCalendarTypeById(req, res); - } -); +router.get("/:id", async (req: Request, res: Response) => { + await getCalendarItemById(req, res); +}); router.post( - "/item", + "/", PermissionHelper.passCheckMiddleware("create", "club", "calendar"), async (req: Request, res: Response) => { await createCalendarItem(req, res); } ); -router.post( - "/type", - PermissionHelper.passCheckMiddleware("create", "settings", "calendar_type"), - async (req: Request, res: Response) => { - await createCalendarType(req, res); - } -); - router.patch( - "/item/:id", + "/:id", PermissionHelper.passCheckMiddleware("update", "club", "calendar"), async (req: Request, res: Response) => { await updateCalendarItem(req, res); } ); -router.patch( - "/type/:id", - PermissionHelper.passCheckMiddleware("update", "settings", "calendar_type"), - async (req: Request, res: Response) => { - await updateCalendarType(req, res); - } -); - router.delete( - "/item/:id", + "/:id", PermissionHelper.passCheckMiddleware("delete", "club", "calendar"), async (req: Request, res: Response) => { await deleteCalendarItem(req, res); } ); -router.delete( - "/type/:id", - PermissionHelper.passCheckMiddleware("delete", "settings", "calendar_type"), - async (req: Request, res: Response) => { - await deleteCalendarType(req, res); - } -); - export default router; diff --git a/src/routes/admin/calendarType.ts b/src/routes/admin/calendarType.ts new file mode 100644 index 0000000..953036d --- /dev/null +++ b/src/routes/admin/calendarType.ts @@ -0,0 +1,50 @@ +import express, { Request, Response } from "express"; +import { + getCalendarItemById, + getAllCalendarItems, + getAllCalendarTypes, + getCalendarTypeById, + createCalendarItem, + createCalendarType, + updateCalendarItem, + updateCalendarType, + deleteCalendarItem, + deleteCalendarType, +} from "../../controller/admin/calendarController"; +import PermissionHelper from "../../helpers/permissionHelper"; + +var router = express.Router({ mergeParams: true }); + +router.get("/", async (req: Request, res: Response) => { + await getAllCalendarTypes(req, res); +}); + +router.get("/:id", async (req: Request, res: Response) => { + await getCalendarTypeById(req, res); +}); + +router.post( + "/", + PermissionHelper.passCheckMiddleware("create", "settings", "calendar_type"), + async (req: Request, res: Response) => { + await createCalendarType(req, res); + } +); + +router.patch( + "/:id", + PermissionHelper.passCheckMiddleware("update", "settings", "calendar_type"), + async (req: Request, res: Response) => { + await updateCalendarType(req, res); + } +); + +router.delete( + "/:id", + PermissionHelper.passCheckMiddleware("delete", "settings", "calendar_type"), + async (req: Request, res: Response) => { + await deleteCalendarType(req, res); + } +); + +export default router; diff --git a/src/routes/admin/index.ts b/src/routes/admin/index.ts index 3df08e7..b4f5d0c 100644 --- a/src/routes/admin/index.ts +++ b/src/routes/admin/index.ts @@ -6,6 +6,7 @@ import communicationType from "./communicationType"; import executivePosition from "./executivePosition"; import membershipStatus from "./membershipStatus"; import qualification from "./qualification"; +import calendarType from "./calendarType"; import member from "./member"; import protocol from "./protocol"; @@ -35,9 +36,9 @@ router.use( membershipStatus ); router.use("/qualification", PermissionHelper.passCheckMiddleware("read", "settings", "qualification"), qualification); +router.use("/calendartype", PermissionHelper.passCheckMiddleware("read", "settings", "calendar_type"), calendarType); router.use("/member", PermissionHelper.passCheckMiddleware("read", "club", "member"), member); - router.use("/protocol", PermissionHelper.passCheckMiddleware("read", "club", "protocol"), protocol); router.use("/calendar", PermissionHelper.passCheckMiddleware("read", "club", "calendar"), calendar);