This package has been deprecated

Author message:

Discontinued

@league-of-legends-devs/instabuilds
TypeScript icon, indicating that this package has built-in type declarations

0.0.10 • Public • Published

instabuilds

Official NPM module for the website https://instabuilds.gg
Works server-side & browser-side.

Installation

npm install --save @league-of-legends-devs/instabuilds

TODO

  • Replace Axios with lightweight client

  • Docs

  • Methods

    • auth.authenticate()
    • auth.logout()
    • itemSets.upload()
    • itemSets.findById()
    • itemSets.findBySlug()
    • itemSets.edit()
    • itemSets.delete()
    • itemSets.rate()
    • itemSets.hash()
    • _setDefaultItemSetDownloadRoute()
    • download.link.itemSet()
    • users.create()
    • users.me()
    • users.findById()
    • search.itemSets()
    • generations.getAll()
    • generations.getLast()
    • generations.findById()
    • static.getChampions()
    • static.getItems()
    • static.getRoles()
    • static.getMaps()
    • static.getRegions()
    • static.getLastPatchVersion()
    • news.getLast()
    • thirdPartyCode.getOne()
    • recaptcha.getSiteKey()
    • startListeners()
    • stopListeners()
    • isAuthenticated()
  • Events

    • [ ] events.onDownloadBuildRequest()
    • [ ] events.onNewGeneration()
  • Constants
    • CHAMPION_ROLE
    • ITEM_SET_TYPE

Examples

const InstaBuilds = require('@league-of-legends-devs/instabuilds');

const client = new InstaBuilds('Application name');
// Using an API auth key
await client.auth.authenticateWithKey('AUTH_KEY');
// or ...
// Credentials that will be used to retrieve a JSON Web Token internally
await client.auth.authenticate('USERNAME', 'PASSWORD');

// Using ReCAPTCHA :
const reCaptchaSiteKey = await client.recaptcha.getSiteKey();
// => Use it to render a ReCAPTCHA checkbox in a login form, then use the obtained auth token to authenticate

// Register a user (ReCAPTCHA auth token is required)
await client.users.create('RECAPTCHA_AUTH_TOKEN', {
  email: 'bestteemona@riotgames.com',
  region: 'NA',
  login: 'BestTeemoNA',
  password: 'SHR0om$_',
  thirdPartyCode: 'YOLO',
});

const patchVersion = await client.static.getLastPatchVersion();

// Upload an item set to the website
const itemSet = {
  title: 'My dank Ahri waifu build',
  champion: { id: 103 },
  role: { id: InstaBuilds.CHAMPION_ROLE.MIDDLE },
  maps: [11]
  comment: 'Easy build',
  content: {
    blocks: [{
      type: 'First block'
      items: [
        { id: 4004, count: 2 }
      ]
    }]
  }
};
const uploadedItemSet = await client.itemSets.upload(itemSet);

// Listen to the Web Sockets events sent from the server
// This step is required in order to use the 'client.onMessage()' event listeners
client.startListeners();

// Listen to real time events using Web Sockets, like actions on the website
client.events.onDownloadRequest(data => {
  // data.itemSets
  // The user called a download from the website
});

API (TODO: documentation in active redaction)

InstaBuilds.init(applicationName [, opts])

Initialize and returns a new client.

Params :

  • applicationName: String. The name of your application (e.g.: "My InstaBuilds client").
  • opts: optional Object. Options (details coming soon).

Returns :

  • the new client

client.login(authKey) or client.login(userName, password)

Log in to the https://instabuilds.gg server with either a auth key or an username & password. This step is required for some features related to user accounts.
client.login() also starts a micro web sockets client ensuring the server that this client is alive and that it can send signals to it.

Returns :

  • a Promise :
    • Object. null if failed authentication.
      • text: String. The server response.

client.logout()

Log out the client. The same client can log in again with the client.login() function.
As client.login() starts a micro web sockets client ensuring the server that this client is alive, this function stops it.

Returns :

  • a Promise :
    • Object. null if the client failed to log out.
      • text: String. The server response.

client._setDefaultItemSetsDownloadRoute (undocumented)

Override the /downloads/sets-from-lib to /downloads/sets-from-app. Must be undocumented.

client.startListeners()

Start the Web Socket listeners, which are not activated by default. This step is required in order to use the client.onMessage() event listeners.

client.stopListeners()

Stop the Web Socket listeners. These can be restarted later using client.startListeners().

TODO: Rewrite client.get(data, [, params], callback)

Requests some datas to the server.

Params :

  • data: String. The type of data to request. Refer to the "Available data inputs" section below.
  • params: optional Object. Parameters to give to the data request. Depends on the data value.
  • callback: Optional callback function. Executed when the server sent a response. Follows the current schema : function(err, response) {}. If not set, the get() method returns a Promise.
    • err: Error. null if successful request
    • response: Object. The retrieved informations, depending on the data value. null if failed request.

Available data inputs ; each different value will have its own associated response (in the response argument of the callback) :

  • 'patchVersion': Gets the current patch version of the server.
    • response: Object.
      • version: String. Patch version (format : 'X.X.X') of the latest item sets generation. This value can differ from the official patch version, as the server takes a little time to generate the datas for the current patch.
      • generationDate: Date. Date of the latest item sets generation.
  • 'news': Gets the "news" section : announcements, warnings ...
    • response: Object.
      • text: String. The content of the "news" section.
      • date: Date. Date of broadcast.
  • 'itemSets': Gets a list of every item sets in a generation. This counts as a download.
    • params: Object.
      • id: optional String. The id of the item sets generaton (format : 'XXXXXXXXXXXXXXXXXXXXXXXX', see the sets page). If null, get the latest generation.
    • response: Object.
      • date: Date. The generation date of the item sets.
      • itemSets: [Object]. List of the item sets, as JSON objects.
  • 'itemSet': Gets a single item set. This counts as a download.
    • params: Object.
      • Either :
        • generationId: String. The id of the generation (format : 'XXXXXXXXXXXXXXXXXXXXXXXX', see the sets page).
        • itemSetNumber: String or Number
      • Or :
        • generationId: optional String. The id of the generation (format : 'XXXXXXXXXXXXXXXXXXXXXXXX', see the sets page). If null, get the latest generation.
        • championKey: String. The "key" of the champion (e.g.: "MonkeyKing" for Wukong, "AurelionSol" for Aurelion Sol).
    • response: Object.
      • date: Date. The generation date of the item set.
      • itemSet: Object. The item set, as JSON object.
      • type: String. The item sets type. Values : 'generated-riot', 'generated-probuilts', 'custom'.
      • author: String. The author's name of this item set. null if generated by the server.
  • 'userDatas': Gets informations of the current logged in user.
    • response: Object.
      • username: String. User name.
      • lastLogin: Date. Date of last login.
      • itemSets: [Object]]. List of the user item sets, as JSON objects. Contains all the item sets of the user : generated and custom builds.

Returns :

  • if no callback provided, returns a Promise :
    • Object. The retrieved informations, depending on the data value.

client.downloadItemSets(data, [, params], callback)

// TODO

client.send(data, [, params], callback)

// TODO

client.onMessage(data, [, params], action)

// TODO

client.on(data, action)

// TODO

client.submitBug(data, callback)

Params :

  • data: Object.
    • platform: Integer. ID of the platform where the bug is located ('Website' : 1, 'Application' : 2 ...).
    • title: String. Short description of the bug.
    • content: String. Detailed description of the bug.
    • sendAdditionalDatas: Boolean. Set to true to send additional datas to help fix the bug (operation system, default browser and screen resolution).
  • callback: Callback function. Executed when the server sent a response. Follows the current schema : function(err) {}. If not set, the submitBug() method returns a Promise.
    • err: Error. null if failed to submit the bug.

Returns :

  • if no callback provided, returns a Promise.

Privacy and conditions

By using this module, you agree to the terms and conditions and privacy policy of https://instabuilds.gg.

License

The MIT License (MIT)

Copyright (c) 2018 Nicolas COUTIN

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Anyway, if you earn money on my open source work, I will fucking end you :)

Readme

Keywords

none

Package Sidebar

Install

npm i @league-of-legends-devs/instabuilds

Weekly Downloads

2

Version

0.0.10

License

MIT

Unpacked Size

2.9 MB

Total Files

25

Last publish

Collaborators

  • ilshidur