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

Jc/event controllers v2 #34

Merged
merged 4 commits into from
Jan 26, 2024
Merged

Jc/event controllers v2 #34

merged 4 commits into from
Jan 26, 2024

Conversation

jcharlpretorius
Copy link
Collaborator

@jcharlpretorius jcharlpretorius commented Jan 23, 2024

Event controllers:

  • Created basic CRUD controllers (without file upload)
  • Can create verified and regular (non verified) events. Verified events are associated with an organization
  • Checking user permissions and event ownership currently being done inside controllers
  • Added a controller with cursor based pagination for recent events. In the future we can use things like timestamp or id as the cursor, depending on how we want to order the results. I used cursor-based pagination instead of offset pagination because offset pagination does not scale well with db size. Pagination parameters are sent via query params: ?pageSize=<>&cursor=<>
    example using timestamp as cursor:
    First query, no cursor: api/events/recent/?pageSize=2
{
  "data": [
  {most recent event data...},
  {2nd most recent event data ...}
  ],
  "cursor": "2024-01-22T21:32:20.539Z"
}

Subsequent pages: api/events/recent/?pageSize=2&cursor=2024-01-22T21:32:20.539Z

{
  "data": [
  {3rd most recent event data...},
  {4th most recent event data...}
  ],
  "cursor": "2024-01-22T21:22:01.911Z"
}

When we reach the end of the available events the cursor is null

{
  "data": [],
  "cursor": null
}

Organization Controller with Default Role Permissions

  • Added a 'create organization' controller with Prisma transaction for adding the user as the 'Owner' and adding all of the default roles and permissions into the database. This is a bit rough right now but adequate for testing user permission functionality

Copy link
Owner

@AarshShah9 AarshShah9 left a comment

Choose a reason for hiding this comment

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

You killing it with these PRs! I suggested a couple things that we can discuss in the meeting today. As long as we align with Noman I think this is all great

backend/controllers/event.controller.ts Show resolved Hide resolved
backend/controllers/org.controller.ts Show resolved Hide resolved
backend/routes/event.routes.ts Show resolved Hide resolved
backend/utils/fileUpload.ts Show resolved Hide resolved
@AarshShah9 AarshShah9 merged commit 5859ad6 into main Jan 26, 2024
3 checks passed
@AarshShah9 AarshShah9 deleted the JC/event-controllers-V2 branch January 26, 2024 02:28
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.

2 participants