dopecodez / Wikipedia

Wikipedia for node and the browser
MIT License
82 stars 19 forks source link

Implement random page API #4

Closed dopecodez closed 3 years ago

dopecodez commented 3 years ago

There are a lot of new REST APIs for wikipedia present in the REST API docs.

We'll look through them one by one and implement the same. Any one who wants to pick up on any other REST API should ideally open a new issue.

The REST API has a /page​/random​/{format} endpoint which which gives a page in given format. This is something I would love to have in wikipedia. Find more details here.

Implementation for this should follow the summary or related method flow. Remember to write unit tests for all possible scenarios in your new functions, and try to use types as far as possible.

I'll be happy to help anyone who wants to pick this up.

friendofdog commented 3 years ago

Are you still looking for help on this issue? If so, I'd like to pitch in.

I'm not sure what is meant by, "Implementation for this should follow the summary or related method flow". But I'm fine writing tests and using types.

dopecodez commented 3 years ago

Sure, @friendofdog , help with this would be welcome.

You only need to use types and write unit tests, you can ignore the other part

friendofdog commented 3 years ago

Understood, @dopecodez . I wrote tests and a basic implementation. (Pardon me for doing so, I borrowed much from existing tests. First time using Jest.)

As for types, the Wikipedia.org API returns six unique types: 5 kinds of JSON objects or an HTML string. Should I add the missing types to resultTypes.js or is this a bit overkill?

dopecodez commented 3 years ago

I think it's best to borrow from existing tests.

That's an interesting question, I think we can skip over the types not currently present in the package. We would ideally need to implement the method like mobile-sections and the rest before we support the same in random.

I will take a detailed look at your changes once you open an MR, @friendofdog , thanks.

friendofdog commented 3 years ago

Pardon the delay.

I took a look at the return formats from the API and they all looked fairly essential. So I just went ahead and creates types for all of them.

Just made a draft PR, #11. How does it look?

dopecodez commented 3 years ago

Looks good, @friendofdog . Lets continue this conversation there.