Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2 #3

Open
MrScopes opened this issue Jan 29, 2021 · 4 comments
Open

v2 #3

MrScopes opened this issue Jan 29, 2021 · 4 comments
Assignees

Comments

@MrScopes
Copy link
Owner

MrScopes commented Jan 29, 2021

V2 Specific Plans:

  • keep queries and json output small and streamlined
  • prioritize small and plentiful requests instead of one big one
  • token option on methods that require api tokens, example:
    const client = new Client('12345');
    client.me();
    
    // or if you plan to do things for multiple users, this is not stored anywhere.
    const client = new Client();
    client.me({ token: '12345' });
    const media = await client.getMedia(1);
    media.favourite({ token: '12345' });
    this would allow you not to have to make a new client for different tokens, but this will use the default token supplied if no token option is given
@MrScopes MrScopes pinned this issue Jan 29, 2021
@MrScopes MrScopes self-assigned this Jan 29, 2021
@MrScopes
Copy link
Owner Author

MrScopes commented Jan 31, 2021

@system32uwu so what do you think about this:
Media

  • id
  • title
    • romaji
    • english
    • native
    • user Preferred
  • .getDescription()
  • .getStudios()
  • .getGenres()
  • ... fill in the blanks

this would mean more requests but base feedback is small, so

console.log(media.getStudios()); // would return the studios (or the entire info again but with the studios)
// I was thinking .getStudios, .getGenres, etc just appends to the info, but maybe it should be promise based fetching? such as:

media.getStudios().then(studios => console.log(studios))

do you think fetching methods for media, characters, users, etc. should be promise based? or just append to the information

@wiredmatt
Copy link

Hello, to make it as efficient as possible you can implement a function like the one I did in my package, it will merge two objects and fill in the missing properties of each, returning a third object with all the data from those two.

That way you can reduce bandwidth consumption and also data fetching will be faster.

And yes, pretty much everything should be promise based, in case there's an error you need to communicate that to the final app that's going to use your package.

@MrScopes
Copy link
Owner Author

MrScopes commented Feb 1, 2021

Hello, to make it as efficient as possible you can implement a function like the one I did in my package, it will merge two objects and fill in the missing properties of each, returning a third object with all the data from those two.

That way you can reduce bandwidth consumption and also data fetching will be faster.

And yes, pretty much everything should be promise based, in case there's an error you need to communicate that to the final app that's going to use your package.

about to push changes, but I just created some of the fetching methods for media

    const media = await client.getMedia(1);

    const genres = await media.getGenres();
    const tags = await media.getTags();
    const studios = await media.getStudios();
    const meta = await media.getMeta();

    //@ts-ignore
    media.genres = genres;
    //@ts-ignore
    media.tags = tags;
    //@ts-ignore
    media.studios = studios;
    //@ts-ignore
    media.meta = meta;

    console.log(media);

meta is

    description: 'Enter a world in the distant future, where Bounty Hunters roam the solar system. Spike and Jet, bounty hunting partners, set out on journeys in an ever struggling effort to win bounty rewards to survive.<br><br>\n' +
      'While traveling, they meet up with other very interesting people. Could Faye, the beautiful and ridiculously poor gambler, Edward, the computer genius, and Ein, the engineered dog be a good addition to the group?',    
    format: 'TV',
    status: 'FINISHED',
    coverImage: {
      extraLarge: 'https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx1-CXtrrkMpJ8Zq.png',
      large: 'https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx1-CXtrrkMpJ8Zq.png',
      medium: 'https://s4.anilist.co/file/anilistcdn/media/anime/cover/small/bx1-CXtrrkMpJ8Zq.png',
      color: '#f1785d'
    },
    bannerImage: 'https://s4.anilist.co/file/anilistcdn/media/anime/banner/1-T3PJUjFJyRwg.jpg',
    startDate: { year: 1998, month: 4, day: 3 },
    endDate: { year: 1999, month: 4, day: 24 },
    season: 'SPRING',
    seasonYear: 1998

I was considering adding format and status to the base media though

@wiredmatt
Copy link

I like that.

Yes, format and status is important for base media, as well as episodes (usually you get an integer here but sometimes when the anime hasn't been released yet or it's airing it will return null).

About being able to specify a token each time you invoke a function which you showcased earlier, I see it useful if this were to be used in a node environment, having a single instance of the client object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants