Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend create endpoint for admin to create event and also to fetch all events #785

Merged

Conversation

choden-dev
Copy link
Member

@choden-dev choden-dev commented Sep 16, 2024

Admin event creation and paginated fetching events

created two endpoints:

  • GET /events
    • Allows users to do cursor based pagination on the latest events
  • POST /admin/events
    • Simple create operation

Note the changes used for sorting timestamps in server/src/data-layer/services/EventService.ts need to be implemented in BookingHistory as the are currently not being sorted properly 💀.

@choden-dev choden-dev linked an issue Sep 16, 2024 that may be closed by this pull request
6 tasks
Copy link

github-actions bot commented Sep 16, 2024

Visit the preview URL for this PR (updated for commit 16930c9):

https://uasc-ceebc--pr785-657-backend-create-e-067vb7kg.web.app

(expires Mon, 23 Sep 2024 01:38:34 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 36296ceaed1d43e92e7d5e81a72a7bd987560bfa

Comment on lines 161 to 164

public async getEventSnapshot(id: string) {
return await FirestoreCollections.events.doc(id).get()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: do we need documenting?

Comment on lines 697 to 712

/**
* Endpoint for admin to create a new event
*/
@SuccessResponse("201", "Created Event")
@Post("events/create")
public async createNewEvent(@Body() body: CreateEventBody) {
try {
const eventService = new EventService()
await eventService.createEvent(body.data)

this.setStatus(201)
} catch {
this.setStatus(500)
}
}
Copy link
Contributor

@jeffplays2005 jeffplays2005 Sep 16, 2024

Choose a reason for hiding this comment

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

Just for future, should we use GET, POST, PATCH methods to indicate for fetching, creating, editing in the /admin/events/ endpoint?

Copy link
Contributor

Choose a reason for hiding this comment

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

Was also thinking of creating another ticket to address these changes as a few endpoints have some endpoints that could use the three methods instead of explicitly stating "create".

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah actually probably a good idea to do it now

Copy link
Member Author

Choose a reason for hiding this comment

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

we should write a wiki article enforcing this?

Copy link
Contributor

@jeffplays2005 jeffplays2005 left a comment

Choose a reason for hiding this comment

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

:p lgtm!

Copy link
Contributor

@asun555 asun555 left a comment

Choose a reason for hiding this comment

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

LGTM

@choden-dev choden-dev merged commit 1c08f1e into master Sep 16, 2024
8 checks passed
@choden-dev choden-dev deleted the 657-backend-create-endpoint-for-admin-to-create-event branch September 16, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Backend] Create endpoint for admin to create event
3 participants