kodadot / uniquery

Client-based SDK for Polkadot NFTs
https://developers.kodadot.xyz
MIT License
8 stars 3 forks source link

REST api bad pratices #10

Open roiLeo opened 1 year ago

roiLeo commented 1 year ago

Please:

vikiival commented 1 year ago

Hey, thanks for you suggestion! I have a couple of Qs

use kebab-case for urls

Will do!

plural name for ressources

so rename itemList to items ? My brain process was avoiding s in url because people can make typos easily.

use nouns instead of action

ELI5 pls? 🥺

roiLeo commented 1 year ago

so rename itemList to items ? My brain process was avoiding s in url because people can make typos easily.

use nouns instead of action

ELI5 pls? 🥺

Wow, I wouldn't hand over the task of writing an Api to a 5 year old 😅

I was referring to the REST part that should be Stateless:

it should be human readable & easy to extend.

Bonus: It would be top if you could create a Swagger doc for this api specs

vikiival commented 1 year ago

Wow! Now I understand that!

I have just a couple of problems:

  1. I currently cant parse queries like /collections/:id/items
  2. when Is it as query param I can't validate if fields are correct
  3. I need to rethink how the REST magic is built (now it's build on the top of client query.

Other option I have in mind it to fork

https://github.com/unjs/ungh

and write proper api 😅

roiLeo commented 1 year ago

I have just a couple of problems:

  1. I currently cant parse queries like /collections/:id/items
  2. when Is it as query param I can't validate if fields are correct
  3. I need to rethink how the REST magic is built (now it's build on the top of client query.

I would like to help you but I don't have enough knowledge on TS backend (only basic express experience) Like how do you handle different endpoints query? are you wrapping gql with a rest api?

Other option I have in mind it to fork https://github.com/unjs/ungh and write proper api 😅

Code looks simpler & maintenable. I agree with that.

vikiival commented 1 year ago

Like how do you handle different endpoints query? are you wrapping gql with a rest api?

basically what rest this version does it that expect path like /{chain}/{call}/{id}

Then I check the call against the map I have defined (let's assign the result to fn) Last thing I do is make const query = fn(id) Find endpoint based on the chain and wrap it together

Code looks simpler & maintenable. I agree with that.

anime-approve

vikiival commented 10 months ago

Decided to deprecate this one for the sake of #29

roiLeo commented 10 months ago

Decided to deprecate this one for the sake of #29

wdym? new api version? new routes? nitro stack?

vikiival commented 10 months ago

wdym? new api version? new routes? nitro stack?

Like plan to remove the ask function for uniquery and would rather develop hosted version (nitro/hono) based on the client implementation.