This repository was archived by the owner on Sep 8, 2023. It is now read-only.
Make the package tree-shakeable #306
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I decided to rewrite this package to use class composition and return errors instead of throwing them. I also made it tree-shakeable, even though it wasn't a necessity.
Anyway, I probably won't ever get time to finish this, but thought it would be cool to share, in case anyone else had similar needs and wanted to contribute. (I will accept PRs that target my fork's
modular-rewritebranch.)Example usage:
There's also a
Clientclass for unauthenticated requests. Instances ofClienthave asendmethod that doesn't accept aMutationorPrivateQueryobject (onlyQueryobjects, which define an unauthenticated request).To define a new request type, you must declare a class that extends either
Mutation,PrivateQuery, orQuery. The class constructor can take any arguments it wants; they are set byclient.sendcalls. The class should override thesendmethod if it needs access to theClientinstance. It can set its ownurl(whose base URL defaults tohttps://i.instagram.com),headers,searchParams,body, orresponseTypeas instance properties. You can check the existing classes insrc/mutationsorsrc/queriesfor some examples.Alright, that's it!