-
Notifications
You must be signed in to change notification settings - Fork 2
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
backend create endpoint for admin to create event and also to fetch all events #785
Conversation
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 |
|
||
public async getEventSnapshot(id: string) { | ||
return await FirestoreCollections.events.doc(id).get() | ||
} |
There was a problem hiding this comment.
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?
|
||
/** | ||
* 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) | ||
} | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:p lgtm!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Admin event creation and paginated fetching events
created two endpoints:
GET /events
POST /admin/events
Note the changes used for sorting timestamps in
server/src/data-layer/services/EventService.ts
need to be implemented inBookingHistory
as the are currently not being sorted properly 💀.