Skip to content

Instantly share code, notes, and snippets.

@nzkevc
Last active April 12, 2024 04:35
Show Gist options
  • Save nzkevc/23c59bd126b562e859fc80b08019fbc1 to your computer and use it in GitHub Desktop.
Save nzkevc/23c59bd126b562e859fc80b08019fbc1 to your computer and use it in GitHub Desktop.
aspa-v3 backend endpoint layout

Events:

Summary

  • Get all events (non-admin)

    • Get all upcoming events (non-admin)
    • Get all past events (non-admin)
  • Get all members for a certain event (admin)

  • Get a specific event (non-admin)

    • Get specific event's max number of people (non-admin)
  • Get all tickets for a certain event (admin)

    • Get all unpaid tickets for a certain event (admin)
    • Get all paid tickets for a certain event (admin)
    • Get number of tickets for a certain event (non-admin)
  • Create an event (admin)

  • Update an event (admin)

  • Delete an event (admin)

Note: Many of these endpoints will - when the request is sent - return response data (generally events, or users) in json format. Please check the event and user models for detailed descriptions of the accessible fields of this data. (Another reason to check is if the models update and some of these endpoint descriptions become out of date)

Endpoints

  1. Get all events

    • Request: GET /events
    • Response: { "data": [{ event1 }, { event2 }, ...] }
    • Explanation:
      • Gets all events in the database represented as json objects
      • Does NOT require admin privileges
  2. Get all past events

    • Request: GET /events/past
    • Response: { "data": [{ event1 }, { event2 }, ...] }
    • Explanation:
      • Gets all events with eventTime's before the current date, represented as json objects
      • Does NOT require admin privileges
  3. Get all upcoming events

    • Request: GET /events/upcoming
    • Response: { "data": [{ event1 }, { event2 }, ...] }
    • Explanation:
      • Gets all events with eventTime's after the current date, represented as json objects
      • Does NOT require admin privileges
  4. Get specific event based on eventId

    • Request: GET /events/:eventId
    • Response: { "data": { eventTitle: "title", eventDescription: "description", eventLocation: "location", eventTime: time, eventPrice: price, maxSize: maxSize } }
    • Explanation:
      • Gets a specific event given its eventId, i.e., GET {url}/events/123 gets the event with the eventId 123 .
      • Does NOT require admin privileges
  5. Get specific event's max number of people

    • Request: GET /events/:eventId
    • Response: { "data": maxSize (Number)}
    • Explanation:
      • Gets a specific event's max number of people allowed to the event given its eventId
  6. Get all users registered for a certain event

    • Request: GET /events/:eventId/members
    • Response: { "data": [{ user1 }, { user2 }, ...] }
    • Explanation:
      • Gets all users that have registered for a certain event (given eventId)
      • REQUIRES admin privileges
  7. Get all tickets for a certain event

    • Request: GET /events/:eventId/allTickets
    • Response: { "data": [{ ticket1 }, { ticket2 }, ...] }
    • Explanation:
      • Gets all tickets registered for a certain event
  8. Get unpaid tickets for a certain event

    • Request: GET /events/:eventId/unpaidTickets
    • Response: { "data": [{ ticket1 }, { ticket2 }, ...] }
    • Explanation:
      • Gets all tickets registered for a certain event that haven't been paid for
  9. Get paid tickets for a certain event

    • Request: GET /events/:eventId/paidTickets
    • Response: { "data": [{ ticket1 }, { ticket2 }, ...] }
    • Explanation:
      • Gets all tickets registered for a certain event that have confirmed to be paid
  10. Get number of tickets for a certain event

    • Request: GET /events/:eventId/totalTicketNumber
    • Response: { "data": totalTicketNumber (Number) }
    • Explanation:
      • Gets total number of tickets for an event
  11. Create an event

    • Request: POST /events { eventTitle: "title", eventDescription: "description", eventLocation: "location", eventTime: time, eventPrice: price, maxSize: maxSize }
    • Response: { "data": { eventTitle: "title", eventDescription: "description", eventLocation: "location", eventTime: time, eventPrice: price, maxSize: maxSize } }
    • Explanation:
      • Creates an event given event title, description, location, time, and price fields, and returns it in the response
      • REQUIRES admin privileges
  12. Update an event

    • Request: PUT /events/:eventId { eventTitle: "title", eventDescription: "description", eventLocation: "location", eventTime: time, eventPrice: price, maxSize: maxSize, maxSize: maxSize }
    • Response: { "data": { eventTitle: "title", eventDescription: "description", eventLocation: "location", eventTime: time, eventPrice: price, maxSize: maxSize } }
    • Explanation:
      • Given fields in the request body, updates an event accordingly and returns the updated event in the response
      • REQUIRES admin privileges
  13. Delete an event

    • Request: DELETE /events/:eventId
    • Response: { "data": {} }
    • Explanation:
      • Deletes an event
      • REQUIRES admin privileges
      • Status code 204 No Content on successful deletion

Tickets:

Summary

  • Get all tickets (admin)

    • Get all unpaid tickets (admin)
    • Get all paid tickets (admin)
  • Get a specific ticket (user or admin)

  • Create a ticket for an event (user or admin)

  • Checkout the ticket (Stripe payment stuff)

  • Pay for a ticket with cash (admin)

  • Delete a ticket (user or admin)

Note: Many of these endpoints will - when the request is sent - return response data (tickets) in json format. Please check the models for detailed descriptions of the accessible fields of this data. (Another reason to check is if the models update and some of these endpoint descriptions become out of date)

Also, user or admin means either the person associated with the user/account, or the admin has privileges to access the endpoint. Non-admin means anyone can access the endpoint - you don't have to be an admin for it.

Endpoints

  1. Get all tickets

    • Request: GET /tickets
    • Response: { "data": [{ ticket1 }, { ticket2 }, ...] }
    • Explanation:
      • Gets all the tickets in the database
  2. Get all unpaid tickets

    • Request: GET /tickets/unpaidTickets
    • Response: { "data": [{ ticket1 }, { ticket2 }, ...] }
    • Explanation:
      • Gets all the tickets in the database that have not been paid for
  3. Get all paid tickets

    • Request: GET /tickets/paidTickets
    • Response: { "data": [{ ticket1 }, { ticket2 }, ...] }
    • Explanation:
      • Gets all the tickets in the database that have confirmed to be paid
  4. Get a specific ticket

    • Request: GET /tickets/:ticketId
    • Response: { "data": { eventId: "eventId", userId: "userId", registrationDate: registrationDate, waitlist: waitlistNumber, isPaid: true | false, paymentType: "paymentType" | null } }
    • Explanation:
      • Get a specific ticket in the database given the ticketId
  5. Create a ticket for a certain event

    • Request: POST /tickets/:eventId/:userId { eventId: "eventId", userId: "userId", registrationDate: registrationDate, waitlist: waitlistNumber, isPaid: false, paymentType: null }
    • Response: { "data": { eventId: "eventId", userId: "userId", registrationDate: registrationDate, waitlist: waitlistNumber, isPaid: false, paymentType: null } }
    • Explanation:
      • Creates a ticket for a certain event given the eventId and userId (corresponding to the user registering for an event)
  6. Pay for a ticket online

    • Request: PATCH /tickets/:ticketId/pay or whatever Stripe URL thing it is?
    • Response: { "data": { eventId: "eventId", userId: "userId", registrationDate: registrationDate, waitlist: waitlistNumber, isPaid: true, paymentType: "stripe" } }
    • Explanation:
      • Redirects to the payment page? Stripe stuff
      • On SUCCESS, update ticket with isPaid status true and paymentType "stripe"
  7. Pay for a ticket with cash

    • Request: PATCH /tickets/:ticketId/paymentStatus
    • Response: { "data": { eventId: "eventId", userId: "userId", registrationDate: registrationDate, waitList: true | false, isPaid: true, paymentType: "cash" } }
    • Explanation:
      • Updates a ticket so the isPaid status is true and paymentType "cash" corresponding to when a user pays in person for the event with cash
  8. Delete a ticket

    • Request: DELETE /tickets/:eventId
    • Response: { "data": {}} }
    • Explanation:
      • Deletes a ticket from the database, representing a withdrawal from an event

Users:

Summary

  • Get all users (admin)

    • Get all user names (admin)
    • Get number of users (non-admin)
  • Get user based on ID (user or admin)

  • Get all events for a particular user (user or admin)

    • Get upcoming events for particular user (user or admin)
    • Get past events for a particular user (user or admin)
  • Get all tickets for a certain user (user or admin)

    • Get all unpaid tickets for a certain user (user or admin)
    • Get all paid tickets for a certain user (user or admin)
  • Create a user (non-admin)

  • Update a user i.e., user details (user or admin)

    • Update user into admin (admin)
  • Delete a user (user or admin)

Note: user or admin means either the person associated with the user/account, or the admin has privileges to access the endpoint. Non-admin means anyone can access the endpoint - you don't have to be an admin for it.


Future endpoints?

  • Get number of points user has (user or admin)
  • Add single point to user points (???)
  • Remove number of user points (???)

Endpoints

  1. Get all users

    • Request: GET /users
    • Response: { "data": [{ user1 }, { user2 }, ...] }
    • Explanation:
      • Gets all users in the database
  2. Get all user names

    • Request: GET /users/allNames
    • Response: { "data": [fullName1, fullName2, ...] }
    • Explanation:
      • Gets the full names of all users in the database
  3. Get total number of users

    • Request: GET /users/totalNumber
    • Response: { "data": totalNumber }
    • Explanation:
      • Gets the number of users in the database
  4. Get a specific user based on userId

    • Request: GET /users/:userId
    • Response: { "data": { firstName: "firstName", lastName: "lastName", email: "email", role: "role", university: "university", studentId: studentId, skillLevel: "skillLevel"} }
    • Explanation:   - Gets a user from the database given the userId
  5. Get all events for a specific user

    • Request: GET /users/:userId/allEvents
    • Response: { "data": [{ event1 }, { event2 }, ...] }
    • Explanation:
      • Get all the events a user has registered for (past and upcoming), based on their userId.
      • (Backend logic) Checks all tickets with userId corresponding to user, and returns events corresponding to each ticket eventId?
  6. Get upcoming events for a specific user

    • Request: GET /users/:userId/upcomingEvents
    • Response: { "data": [{ event1 }, { event2 }, ...] }
    • Explanation:
      • Get the upcoming events a user has registered for, given their userId.
  7. Get past events for a specific user

    • Request: GET /users/:userId/pastEvents
    • Response: { "data": [{ event1 }, { event2 }, ...] }
    • Explanation:
      • Get the past events a user has registered for, given their userId.
  8. Get all tickets for a certain user

    • Request: GET /users/:userId/allTickets
    • Response: { "data": [{ ticket1 }, { ticket2 }, ...] }
    • Explanation:
      • Get all tickets for events a certain user has registered for
  9. Get unpaid tickets for a certain user

    • Request: GET /users/:userId/unpaidTickets
    • Response: { "data": [{ ticket1 }, { ticket2 }, ...] }
    • Explanation:
      • Get unpaid tickets for events a certain user has registered for
  10. Get paid tickets for a certain user

    • Request: GET /users/:userId/paidTickets
    • Response: { "data": [{ ticket1 }, { ticket2 }, ...] }
    • Explanation:
      • Get paid tickets for events a certain user has registered for
  11. Create a user

    • Request: POST /users { firstName: "firstName", lastName: "lastName", email: "email", role: "role", university: "university", studentId: studentId, skillLevel: "skillLevel"}
    • Response: { "data": { firstName: "firstName", lastName: "lastName", email: "email", role: "role", university: "university", studentId: studentId, skillLevel: "skillLevel"} }
    • Explanation:
      • Creates a user in the database and returns it in the response if successful
  12. Update user details

    • Request: PUT /users/:userId { firstName: "firstName", lastName: "lastName", email: "email", university: "university", studentId: studentId, skillLevel: "skillLevel"}
    • Response: { "data": { firstName: "firstName", lastName: "lastName", email: "email", role: "role", university: "university", studentId: studentId, skillLevel: "skillLevel"} }
    • Explanation:
      • Given fields in the request body, updates a user accordingly
      • (Bakend logic) Should implement check so non-admins cannot update the user into an admin
  13. Update user to admin

    • Request: PATCH /users/:userId/admin
    • Response: { "data": { firstName: "firstName", lastName: "lastName", email: "email", role: "admin", university: "university", studentId: studentId, skillLevel: "skillLevel"} }
    • Explanation:
      • Updates a user into admin (changes the admin role)
      • REQUIRES admin privileges and should check for this
  14. Delete a user

    • Request: DELETE /users/:userId
    • Response: { "data": {} }
    • Explanation:
      • Deletes a user from the database given the userId
      • Status code 204 No Content on successful deletion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment