#REST API route logic

9 messages · Page 1 of 1 (latest)

shell furnace
#

I would like to create a trello clone. I trying to figure out the logic. The really "bottom" route something like this:
api/workspace/:id/board/:id/list/:id/card/:id

It seems a bit complex for URI, so I am not sure what would be the good approach here, how should I organize az API routes.

The model structure: workspace has relation to board, board has relation to list, list has relation to card.

The reason of chain, I have to get worskapceId if I am at board route because I have to set relation between board and worskapce model

Can you give me advice about the structure, route etc. ?

night geyserBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

sterile coral
#

If you want to remain restful, consider if a card belongs to a list, and a list to a board. If a list can change boards, or a card can change lists, you should not make it a nested collection. So you would have the different collections available as:

api/workspaces/:id
api/boards/:id
api/cards/:id

you should then create endpoints that allow you to retrieve the collections associated with a given id

api/workspaces/:id/boards
api/boards/:id/cards

but it wont be possible to keep digging more than that.

api/workspace/:id/boards/:id // Not valid, if you want to access the board, use the boards endpoint
api/board/:id // Correct!
#

for UI pages routing, consider using intercepting routes.

/boards // shows the boards
/boards/[id] // shows you a specific board
/card/[id] // shows you a card as a stand alone page
/boards/(..)card/[id] // shows you card as a modal, this intercepts the route that goes to the standalone page when the user is on the boards page
shell furnace
#

So i should combine the board route with workspace, the list with board and the card with list

#

but I do not need to do many nesting routes

#

it seems logical, a little bit not so direct, but the model 'chain' stucture needs to solve in a not so generic way like api/workspaces/:id and need to create separate routes for workspace-board, board-list, list-card relataions

#

and the solution seems logical and clean if I want to extend anything, than easy to add

#

thank you