fix(api): validate timestamps when creating events and allow setting a location

This commit is contained in:
Dominik 2025-06-16 10:07:17 +02:00
parent 2d7196211f
commit 19e07d9980
Signed by: dominik
GPG key ID: 06A4003FC5049644
2 changed files with 31 additions and 1 deletions

View file

@ -397,6 +397,12 @@ export const PATCH = auth(async (req, { params }) => {
}
updateData.end_time = endTimeValidation.getTime().toString();
}
if (new Date(start_time) >= new Date(end_time)) {
return NextResponse.json(
{ success: false, message: 'start_time must be before end_time' },
{ status: 400 },
);
}
if (location) updateData.location = location;
if (status) {
const validStatuses = ['TENTATIVE', 'CONFIRMED', 'CANCELLED'];