cal.com icon indicating copy to clipboard operation
cal.com copied to clipboard

help migrate legacy pages/api/ endpoints to tRPC

Open PeerRich opened this issue 3 years ago • 5 comments
trafficstars

https://github.com/calcom/cal.com/tree/main/apps/web/pages/api

@zomars wanna make a list of endpoints?

@zomars EDIT:

  • [ ] /api/availability/[user]
    • [ ] GET -> query viewer.availability.user
  • [ ] /api/availability/calendar
    • [ ] GET -> query viewer.selectedCalendars.list
    • [ ] DELETE -> mutation viewer.selectedCalendars.delete
    • [ ] POST -> mutation viewer.selectedCalendars.createOrUpdate OR viewer.availability.calendar.upsert
  • [ ] /api/availability/day (DEPRECATED)
  • [ ] /api/availability/eventtype
    • [ ] POST -> mutation viewer.eventTypes.create
    • [ ] PATCH -> mutation viewer.eventTypes.update
    • [ ] DELETE -> mutation viewer.eventTypes.delete
  • [ ] /api/book/confirm
    • [ ] GET -> query viewer.book.confirm
  • [ ] /api/book/event
    • [ ] POST -> mutation viewer.book.event
  • [ ] /api/book/request-reschedule
    • [ ] POST -> mutation viewer.book.requestReschedule
  • [ ] /api/event-type/index
    • [ ] GET -> query viewer.eventTypes.list

WIP...

PeerRich avatar Jul 28 '22 17:07 PeerRich

Hi, I would like to pick this issue

hussamkhatib avatar Jul 28 '22 17:07 hussamkhatib

Hi, I would like to pick this issue

assigned

PeerRich avatar Jul 28 '22 17:07 PeerRich

Updated issue with initial list. Will add more later

zomars avatar Jul 28 '22 19:07 zomars

Hi Maintainers, I am working on this endpoint currently.

/api/book/confirm GET -> query viewer.book.confirm

The above should be a POST method in trpc. See below : BookingListItem.tsx

      const res = await fetch("/api/book/confirm", {
       method: "PATCH",
       body: JSON.stringify(body),
       headers: {
         "Content-Type": "application/json",
       },
     });

Also for query viewer.book.confirm should it not be viewer.booking.confirm as I can think that is what it is meant for and there already exist a route for that. viewer/bookings.tsx

hussamkhatib avatar Aug 06 '22 06:08 hussamkhatib

  • The route /api/event-type/index route does not exist.

This is not used anywhere

/api/availability/day (DEPRECATED)

Should I go on and delete this file and it's occurence in calendso.yaml


  • /api/availability/eventtype

    • POST -> mutation viewer.eventTypes.create
    • PATCH -> mutation viewer.eventTypes.update
    • DELETE -> mutation viewer.eventTypes.delete

    All the 3 methods already exists. link : trpc/server/routers/viewer/eventTypes.tsx Should delete this file and and it's occurence in calendso.yaml


@PeerRich Can you update the original list by checking on what's done and removing what's not required ?

hussamkhatib avatar Aug 07 '22 08:08 hussamkhatib

HI @PeerRich , can you update the todos, the below endpoints are completed in previous PR.

  • [x] /api/book/confirm
  • [x] /api/availability/day
  • [x] /api/availability/eventtype // all methods
  • [x] /api/event-type

hussamkhatib avatar Aug 30 '22 18:08 hussamkhatib

Done!

zomars avatar Aug 30 '22 18:08 zomars

Hey @zomars, Could help me get through this PR https://github.com/calcom/cal.com/pull/7234 It's WIP and currently blocked by typeScript issue which I am not able to debug it.

hussamkhatib avatar Feb 20 '23 17:02 hussamkhatib

closing due to stale. feel free to open a new issue

PeerRich avatar May 17 '23 16:05 PeerRich