mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
(refactor): create a ServiceProvider for the Jax wrapper
This commit is contained in:
parent
3653508816
commit
5b964f14ba
14 changed files with 26 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const Jax = use('App/Lib/Jax')
|
const Jax = use('Jax')
|
||||||
|
|
||||||
class DDragonController {
|
class DDragonController {
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const Match = use('App/Models/Match')
|
const Match = use('App/Models/Match')
|
||||||
const Jax = use('App/Lib/Jax')
|
const Jax = use('Jax')
|
||||||
|
|
||||||
class SummonerController {
|
class SummonerController {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
module.exports = require('./Jax')
|
|
||||||
17
server/providers/Jax/JaxProvider.js
Normal file
17
server/providers/Jax/JaxProvider.js
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
const { ServiceProvider } = require('@adonisjs/fold')
|
||||||
|
const Jax = require('./src/Jax')
|
||||||
|
|
||||||
|
class JaxProvider extends ServiceProvider {
|
||||||
|
register () {
|
||||||
|
this.app.singleton('Jax', () => {
|
||||||
|
const Env = use('Env')
|
||||||
|
return new Jax(Env.get('API_KEY'))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
boot() {
|
||||||
|
use('Jax')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = JaxProvider
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
const Env = use('Env')
|
|
||||||
const RiotRateLimiter = require('riot-ratelimiter')
|
const RiotRateLimiter = require('riot-ratelimiter')
|
||||||
const { STRATEGY } = require('riot-ratelimiter/dist/RateLimiter')
|
const { STRATEGY } = require('riot-ratelimiter/dist/RateLimiter')
|
||||||
const LeagueEndpoint = require('./Endpoints/LeagueEndpoint')
|
const LeagueEndpoint = require('./Endpoints/LeagueEndpoint')
|
||||||
|
|
@ -10,8 +9,7 @@ const DDragonVersionEndpoint = require('./Endpoints/DDragonEndpoints/DDragonVers
|
||||||
const DDragonChampionEndpoint = require('./Endpoints/DDragonEndpoints/DDragonChampionEndpoint')
|
const DDragonChampionEndpoint = require('./Endpoints/DDragonEndpoints/DDragonChampionEndpoint')
|
||||||
|
|
||||||
class Jax {
|
class Jax {
|
||||||
constructor(key = Env.get('API_KEY'), region = 'euw1') {
|
constructor(key, region = 'euw1') {
|
||||||
|
|
||||||
this.key = key
|
this.key = key
|
||||||
const limiterOptions = {
|
const limiterOptions = {
|
||||||
strategy: STRATEGY.BURST
|
strategy: STRATEGY.BURST
|
||||||
|
|
@ -48,4 +46,4 @@ class Jax {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = new Jax()
|
module.exports = Jax
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
const { join } = require('path')
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Providers
|
| Providers
|
||||||
|
|
@ -14,7 +16,9 @@ const providers = [
|
||||||
'@adonisjs/framework/providers/AppProvider',
|
'@adonisjs/framework/providers/AppProvider',
|
||||||
'@adonisjs/bodyparser/providers/BodyParserProvider',
|
'@adonisjs/bodyparser/providers/BodyParserProvider',
|
||||||
'@adonisjs/cors/providers/CorsProvider',
|
'@adonisjs/cors/providers/CorsProvider',
|
||||||
'lucid-mongo/providers/LucidMongoProvider'
|
'lucid-mongo/providers/LucidMongoProvider',
|
||||||
|
|
||||||
|
join(__dirname, '../providers/Jax/JaxProvider')
|
||||||
]
|
]
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue