diff --git a/client/src/store/index.js b/client/src/store/index.js index 3f9e7bc..e7aa39d 100644 --- a/client/src/store/index.js +++ b/client/src/store/index.js @@ -1,6 +1,5 @@ import Vue from 'vue' import Vuex from 'vuex' -import * as ddragon from '@/store/modules/ddragon' import * as detailedMatch from '@/store/modules/detailedMatch' import * as notification from '@/store/modules/notification' import * as settings from '@/store/modules/settings' @@ -12,7 +11,6 @@ const debug = process.env.NODE_ENV !== 'production' export default new Vuex.Store({ modules: { - ddragon, detailedMatch, notification, settings, diff --git a/client/src/store/modules/ddragon.js b/client/src/store/modules/ddragon.js deleted file mode 100644 index fa15e47..0000000 --- a/client/src/store/modules/ddragon.js +++ /dev/null @@ -1,46 +0,0 @@ -import { axios } from '@/plugins/axios' - -export const namespaced = true - -export const state = { - champions: [], - runes: [], - version: '' -} - -export const mutations = { - PUSH_CHAMPIONS(state, champions) { - state.champions = champions - }, - PUSH_RUNES(state, runes) { - state.runes = runes - }, - PUSH_VERSION(state, version) { - state.version = version - } -} - -export const actions = { - async getChampions({ commit }) { - console.log('API CALL FOR CHAMPIONS') - const endpoint = 'Champion' - const resp = await axios(({ url: 'ddragon', data: { endpoint }, method: 'POST' })) - commit('PUSH_CHAMPIONS', resp.data.data) - }, - - async getRunes({ commit }) { - console.log('API CALL FOR RUNES') - const endpoint = 'Rune' - const resp = await axios(({ url: 'ddragon', data: { endpoint }, method: 'POST' })) - commit('PUSH_RUNES', resp.data) - }, - - getVersion({ commit }, version) { - commit('PUSH_VERSION', version) - }, -} - -export const getters = { - areChampionsLoaded: state => !!state.champions.Aatrox, - version: state => state.version -} diff --git a/server/app/Controllers/Http/DDragonController.js b/server/app/Controllers/Http/DDragonController.js deleted file mode 100644 index f0c2b03..0000000 --- a/server/app/Controllers/Http/DDragonController.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict' - -const Jax = use('Jax') - -class DDragonController { - /** - * POST - Return infos about all static Ddragon data - */ - async index({ request, response }) { - console.log('DDragon Request') - const endpoint = request.input('endpoint') - const result = await Jax.DDragon[endpoint].list() - response.json(result) - } -} - -module.exports = DDragonController diff --git a/server/app/Transformers/MatchTransformer.js b/server/app/Transformers/MatchTransformer.js index 5ec6f7f..cb7d798 100644 --- a/server/app/Transformers/MatchTransformer.js +++ b/server/app/Transformers/MatchTransformer.js @@ -10,7 +10,7 @@ const Helpers = use('App/helpers') */ class MatchTransformer { /** - * Get global Context with DDragon Data + * Get global Context with CDragon Data */ async getContext() { const items = await Jax.CDragon.items() diff --git a/server/providers/Jax/src/DDragonRequest.js b/server/providers/Jax/src/DDragonRequest.js deleted file mode 100644 index cf277cd..0000000 --- a/server/providers/Jax/src/DDragonRequest.js +++ /dev/null @@ -1,33 +0,0 @@ -const got = require('got') - -class DDragonRequest { - constructor(endpoint, type, version) { - this.endpoint = endpoint - this.type = type - this.version = version - - this.lang = 'en_US' - } - - // https://ddragon.leagueoflegends.com/cdn/${this.$patch}/data/en_US/champion.json - // https://ddragon.leagueoflegends.com/api/versions.json - - async execute() { - let url; - if (this.version) { - url = `https://ddragon.leagueoflegends.com/${this.type}/${this.version}/data/${this.lang}/${this.endpoint}` - } else { - url = `https://ddragon.leagueoflegends.com/${this.type}/${this.endpoint}` - } - - try { - const response = await got(url); - return JSON.parse(response.body) - } catch (error) { - console.log(error.response.body); - } - } - -} - -module.exports = DDragonRequest diff --git a/server/providers/Jax/src/Endpoints/DDragonEndpoints/DDragonChampionEndpoint.js b/server/providers/Jax/src/Endpoints/DDragonEndpoints/DDragonChampionEndpoint.js deleted file mode 100644 index 1d0607c..0000000 --- a/server/providers/Jax/src/Endpoints/DDragonEndpoints/DDragonChampionEndpoint.js +++ /dev/null @@ -1,17 +0,0 @@ -const DDragonRequest = require('../../DDragonRequest') - -class DDragonChampionEndpoint { - constructor(version) { - this.version = version - } - - list() { - return new DDragonRequest( - `champion.json`, - 'cdn', - this.version - ).execute() - } -} - -module.exports = DDragonChampionEndpoint diff --git a/server/providers/Jax/src/Endpoints/DDragonEndpoints/DDragonItemEndpoint.js b/server/providers/Jax/src/Endpoints/DDragonEndpoints/DDragonItemEndpoint.js deleted file mode 100644 index 2f26957..0000000 --- a/server/providers/Jax/src/Endpoints/DDragonEndpoints/DDragonItemEndpoint.js +++ /dev/null @@ -1,17 +0,0 @@ -const DDragonRequest = require('../../DDragonRequest') - -class DDragonItemEndpoint { - constructor(version) { - this.version = version - } - - list() { - return new DDragonRequest( - `item.json`, - 'cdn', - this.version - ).execute() - } -} - -module.exports = DDragonItemEndpoint diff --git a/server/providers/Jax/src/Endpoints/DDragonEndpoints/DDragonRuneEndpoint.js b/server/providers/Jax/src/Endpoints/DDragonEndpoints/DDragonRuneEndpoint.js deleted file mode 100644 index a190ef2..0000000 --- a/server/providers/Jax/src/Endpoints/DDragonEndpoints/DDragonRuneEndpoint.js +++ /dev/null @@ -1,17 +0,0 @@ -const DDragonRequest = require('../../DDragonRequest') - -class DDragonRuneEndpoint { - constructor(version) { - this.version = version - } - - list() { - return new DDragonRequest( - `runesReforged.json`, - 'cdn', - this.version - ).execute() - } -} - -module.exports = DDragonRuneEndpoint diff --git a/server/providers/Jax/src/Endpoints/DDragonEndpoints/DDragonVersionEndpoint.js b/server/providers/Jax/src/Endpoints/DDragonEndpoints/DDragonVersionEndpoint.js deleted file mode 100644 index 76f5d62..0000000 --- a/server/providers/Jax/src/Endpoints/DDragonEndpoints/DDragonVersionEndpoint.js +++ /dev/null @@ -1,13 +0,0 @@ -const DDragonRequest = require('../../DDragonRequest') - -class DDragonVersionEndpoint { - list() { - return new DDragonRequest( - `versions.json`, - 'api', - null - ).execute() - } -} - -module.exports = DDragonVersionEndpoint diff --git a/server/providers/Jax/src/Jax.js b/server/providers/Jax/src/Jax.js index fdf4ade..0541643 100644 --- a/server/providers/Jax/src/Jax.js +++ b/server/providers/Jax/src/Jax.js @@ -5,11 +5,6 @@ const MatchlistEndpoint = require('./Endpoints/MatchlistEndpoint') const SpectatorEndpoint = require('./Endpoints/SpectatorEndpoint') const SummonerEndpoint = require('./Endpoints/SummonerEndpoint') -const DDragonVersionEndpoint = require('./Endpoints/DDragonEndpoints/DDragonVersionEndpoint') -const DDragonChampionEndpoint = require('./Endpoints/DDragonEndpoints/DDragonChampionEndpoint') -const DDragonRuneEndpoint = require('./Endpoints/DDragonEndpoints/DDragonRuneEndpoint') -const DDragonItemEndpoint = require('./Endpoints/DDragonEndpoints/DDragonItemEndpoint') - const CDragonEndpoint = require('./Endpoints/CDragonEndpoint') class Jax { @@ -27,25 +22,12 @@ class Jax { this.Spectator = new SpectatorEndpoint(this.config, this.limiter) this.Summoner = new SummonerEndpoint(this.config, this.limiter) - this.initDDragon() - this.CDragon = new CDragonEndpoint() } - async initDDragon() { - this.version = (await new DDragonVersionEndpoint().list())[0] - - this.DDragon = { - Champion: new DDragonChampionEndpoint(this.version), - Item: new DDragonItemEndpoint(this.version), - Rune: new DDragonRuneEndpoint(this.version), - Version: this.version - } - } - set regionName(regionName) { this.config.region = regionName - const blacklistedProperties = ['key', 'limiter', 'config', 'version', 'DDragon'] + const blacklistedProperties = ['key', 'limiter', 'config', 'version', 'CDragon'] for (const key of Object.getOwnPropertyNames(this)) { if(blacklistedProperties.includes(key)) continue diff --git a/server/start/routes.js b/server/start/routes.js index 6492e87..9b657a5 100644 --- a/server/start/routes.js +++ b/server/start/routes.js @@ -20,7 +20,7 @@ const Match = use('App/Models/Match') Route.get('/', async () => { return { - greeting: 'Hello world in JSON', + greeting: 'Hello world from LeagueStats.gg', match: await Match.first() } }) @@ -30,7 +30,6 @@ Route.post('/summoner-overview', 'SummonerController.overview') Route.post('/summoner-champions', 'SummonerController.champions') Route.post('/summoner-records', 'SummonerController.records') Route.post('/summoner-live', 'SummonerController.liveMatchDetails') -Route.post('/ddragon', 'DDragonController.index') Route.post('/match', 'MatchController.index') Route.post('/match-details', 'MatchController.show') Route.post('/match-details-ranks', 'MatchController.showRanks')