Skip to content

Commit

Permalink
no eventId in put or post
Browse files Browse the repository at this point in the history
  • Loading branch information
aletya committed Aug 7, 2024
1 parent fa205e1 commit 7843da2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/services/events/events-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ eventsRouter.post(
RoleChecker([Role.Enum.STAFF]),
async (req, res, next) => {
try {
if (req.body.eventId) {
return res.status(StatusCodes.BAD_REQUEST).json({
error: "Invalid Parameters",
});
}
const validatedData = privateEventValidator.parse(req.body);
const event = new Database.EVENTS(validatedData);
await event.save();
Expand All @@ -118,7 +123,13 @@ eventsRouter.put(
async (req, res, next) => {
const eventId = req.params.EVENTID;
try {
if (req.body.eventId) {
return res.status(StatusCodes.BAD_REQUEST).json({
error: "Invalid Parameters",
});
}
const validatedData = privateEventValidator.parse(req.body);
validatedData.eventId = eventId;
const event = await Database.EVENTS.findOneAndUpdate(
{ eventId: eventId },
{ $set: validatedData }
Expand Down

0 comments on commit 7843da2

Please sign in to comment.