Skip to content

feat: api routes for bookings and events query#40

Merged
TheMythologist merged 7 commits intomainfrom
feature/api-routes
Jan 7, 2026
Merged

feat: api routes for bookings and events query#40
TheMythologist merged 7 commits intomainfrom
feature/api-routes

Conversation

@ThePeeKayy
Copy link
Contributor

@ThePeeKayy ThePeeKayy commented Dec 18, 2025

Resolves #16

@ThePeeKayy ThePeeKayy self-assigned this Dec 18, 2025
@vercel
Copy link

vercel bot commented Dec 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
nusc-website Ready Ready Preview, Comment Dec 20, 2025 4:25am

Copy link
Collaborator

@TheMythologist TheMythologist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read through the comments and update this branch! Feel free to PM me if you have any questions

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you refactor to use request.nextUrl.searchParams instead? No need to cast it to a new URL
https://nextjs.org/docs/app/api-reference/file-conventions/route#url-query-parameters

Comment on lines +8 to +12
const bookingName = url.searchParams.get('bookingName');
const start = url.searchParams.get('start');
const end = url.searchParams.get('end');
const venue = url.searchParams.get('venue');
const organisation = url.searchParams.get('organisation');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use zod to validate the type and searchParams, casting it to a Date or number if necessary.

For an example, refer to https://github.com/usdevs/NUSCweb/blob/main/src/lib/schema/booking.ts

const venue = url.searchParams.get('venue');
const organisation = url.searchParams.get('organisation');

let bookings = await getBookings();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of getting all bookings and then filter manually on our server, instead pass the filters through Prisma and only return the necessary bookings

Refer to https://www.prisma.io/docs/orm/prisma-client/queries/filtering-and-sorting for documentation

Comment on lines +6 to +14
const url = new URL(request.url);

const orgName = url.searchParams.get('orgName');
const start = url.searchParams.get('start');
const end = url.searchParams.get('end');
const venue = url.searchParams.get('venue');
const organisation = url.searchParams.get('organisation');

let events = await getEvents();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments here as the previous file

@ThePeeKayy ThePeeKayy changed the title Add endpoints Resolves #16 Dec 19, 2025
@ThePeeKayy ThePeeKayy linked an issue Dec 19, 2025 that may be closed by this pull request
2 tasks
@github-actions github-actions bot added the dependencies Pull requests that update a dependency file label Dec 20, 2025
@TheMythologist TheMythologist changed the title Resolves #16 feat: api routes for bookings and events query Dec 20, 2025
@TheMythologist TheMythologist merged commit c77c839 into main Jan 7, 2026
3 checks passed
@TheMythologist TheMythologist deleted the feature/api-routes branch January 7, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement APIs for easy retrieval of bookings/events

2 participants