refactor: change RiotLimiter strategy according to environment

This commit is contained in:
Valentin Kaelin 2019-09-13 18:25:33 +02:00
parent 3dfd4d87a6
commit db939459a0
2 changed files with 4 additions and 4 deletions

View file

@ -5,7 +5,7 @@ class JaxProvider extends ServiceProvider {
register () {
this.app.singleton('Jax', () => {
const Env = use('Env')
return new Jax(Env.get('API_KEY'))
return new Jax(Env.get('API_KEY'), Env.get('NODE_ENV'))
})
}

View file

@ -9,13 +9,13 @@ const DDragonVersionEndpoint = require('./Endpoints/DDragonEndpoints/DDragonVers
const DDragonChampionEndpoint = require('./Endpoints/DDragonEndpoints/DDragonChampionEndpoint')
class Jax {
constructor(key, region = 'euw1') {
constructor(key, env) {
this.key = key
const limiterOptions = {
strategy: STRATEGY.BURST
strategy: env === 'production' ? STRATEGY.SPREAD : STRATEGY.BURST
}
this.limiter = new RiotRateLimiter(limiterOptions)
this.region = region
this.region = 'euw1'
this.League = new LeagueEndpoint(this.limiter, this.region)
this.Match = new MatchEndpoint(this.limiter, this.region)