itsthatguy / itsthatguy/avatars-api-middleware

Discussion: a better routing schema

Open
#76 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
744
Forks
97
PR merge metrics
No merged PRs in 30d

Description

cc @rylnd

This was the last issue I had in mind to do, I promise!

Right now the endpoint set look like this:

```
/myAvatars/:id
/myAvatars/:size/:id
/myAvatars/face/:eyes/:nose/:mouth/:color
/myAvatars/face/:eyes/:nose/:mouth/:color/:size
/myAvatars/list
```
and as a developer I found it a bit confusing and hard coded.
So after some experiment I would propose you to implement the whole thing in a different way that (assuming #74 will land) should follow this schema:

| root | scope | optional size | params |
| -- | -- | -- | -- |
| avatars | face | * | :id |
| avatars | face | :size | :id |
| avatars | face | * | :eyes/:nose/:mouth/:color |
| avatars | face | :size | :eyes/:nose/:mouth/:color |
| avatars | meta | * | list |
| avatars | meta | :size | list |
| avatars | meta | * | random |
| avatars | meta | :size | random |

I tried this new routing system on my local setup and it feels pretty good, being way more predictable and scalable. Also it doesn't add almost any logic on top of what exists now.

If you are wondering about ```\avatars\meta\:size\list``` I was thinking about letting ```list``` return an object like

```
{
face: {...},
size: :size
}
```

This add the ability to programmatically get the default size (or any size), that is another thing I find pretty useful.

Any thoughts?

Contributor guide

Open the contributing guide

Research direction

Review the current endpoint set in the issue and compare it with the proposed routing schema, including the dependency on #74. Before changing code, resolve the open design questions around the schema and the metadata response; done means the routing behavior and response shape are explicitly agreed.

Written by the indexing model from the issue text.

Assessment

Tech stack
express, typescript
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.