This commit is contained in:
Julian Krauser 2024-11-24 15:31:06 +01:00
parent 9dfc55d7f6
commit 4fbe108e3d
3 changed files with 61 additions and 58 deletions

View file

@ -15,84 +15,36 @@ import PermissionHelper from "../../helpers/permissionHelper";
var router = express.Router({ mergeParams: true }); var router = express.Router({ mergeParams: true });
router.get( router.get("/", async (req: Request, res: Response) => {
"/items", await getAllCalendarItems(req, res);
PermissionHelper.passCheckMiddleware("read", "club", "calendar"), });
async (req: Request, res: Response) => {
await getAllCalendarItems(req, res);
}
);
router.get( router.get("/:id", async (req: Request, res: Response) => {
"/item/:id", await getCalendarItemById(req, res);
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.post( router.post(
"/item", "/",
PermissionHelper.passCheckMiddleware("create", "club", "calendar"), PermissionHelper.passCheckMiddleware("create", "club", "calendar"),
async (req: Request, res: Response) => { async (req: Request, res: Response) => {
await createCalendarItem(req, res); await createCalendarItem(req, res);
} }
); );
router.post(
"/type",
PermissionHelper.passCheckMiddleware("create", "settings", "calendar_type"),
async (req: Request, res: Response) => {
await createCalendarType(req, res);
}
);
router.patch( router.patch(
"/item/:id", "/:id",
PermissionHelper.passCheckMiddleware("update", "club", "calendar"), PermissionHelper.passCheckMiddleware("update", "club", "calendar"),
async (req: Request, res: Response) => { async (req: Request, res: Response) => {
await updateCalendarItem(req, res); 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( router.delete(
"/item/:id", "/:id",
PermissionHelper.passCheckMiddleware("delete", "club", "calendar"), PermissionHelper.passCheckMiddleware("delete", "club", "calendar"),
async (req: Request, res: Response) => { async (req: Request, res: Response) => {
await deleteCalendarItem(req, res); 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; export default router;

View file

@ -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;

View file

@ -6,6 +6,7 @@ import communicationType from "./communicationType";
import executivePosition from "./executivePosition"; import executivePosition from "./executivePosition";
import membershipStatus from "./membershipStatus"; import membershipStatus from "./membershipStatus";
import qualification from "./qualification"; import qualification from "./qualification";
import calendarType from "./calendarType";
import member from "./member"; import member from "./member";
import protocol from "./protocol"; import protocol from "./protocol";
@ -35,9 +36,9 @@ router.use(
membershipStatus membershipStatus
); );
router.use("/qualification", PermissionHelper.passCheckMiddleware("read", "settings", "qualification"), qualification); 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("/member", PermissionHelper.passCheckMiddleware("read", "club", "member"), member);
router.use("/protocol", PermissionHelper.passCheckMiddleware("read", "club", "protocol"), protocol); router.use("/protocol", PermissionHelper.passCheckMiddleware("read", "club", "protocol"), protocol);
router.use("/calendar", PermissionHelper.passCheckMiddleware("read", "club", "calendar"), calendar); router.use("/calendar", PermissionHelper.passCheckMiddleware("read", "club", "calendar"), calendar);