Created
November 7, 2017 22:08
-
-
Save Pyrolistical/2c3e4e3797140a20856ba6c681285878 to your computer and use it in GitHub Desktop.
Steven interview code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (lolClient) => { | |
return { | |
method: 'GET', | |
path: '/v1/lol/summoner/getByName/{summonerName}', | |
handler({query: {region}, params: {summonerName}}, reply) { | |
return lolClient.Summoner.gettingByName(summonerName) | |
.then((summoner) => { | |
if (!summoner) { | |
return reply(Boom.notFound(`Summoner was not found | |
${summonerName} not found`)); | |
} | |
return reply(summoner); | |
}) | |
.catch((err) => { | |
return reply(Boom.badImplementation(err)); | |
}) | |
} | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.state.playerInfoLoaded ? <Container fluid>... : <div></div> | |
this.state.playerInfoLoaded ? <Container fluid>... : '' | |
this.state.playerInfoLoaded && <Container fluid> | |
<h1 class={'something' + else }>{foo + ' is awesome'}</h1> | |
<h1 class={'something' + else }>{foo} is awesome</h1> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _ = require('lodash'); | |
const LeagueJS = require('leaguejs'); | |
const Hapi = require('hapi'); | |
const SummonerController = require('./summoner/controller') | |
module.exports = class LolStatsAPIServer { | |
/** | |
* | |
* @param {*} options Required props: port, host, apiKey, routeConfig | |
*/ | |
constructor(options) { | |
//Initialize HapiJS webserver | |
this.webServer = new Hapi.Server({ | |
connections: { | |
routes: { | |
cors: true | |
} | |
} | |
}); | |
this.webServer.connection({ port: options.port, host: options.host }); | |
//Initialize LeagueJS Client | |
const lolClient = new LeagueJS(options.apiKey); | |
lolClient.updateRateLimiter({ | |
allowBursts: true | |
}); | |
this.webServer.route(SummonerController(lolClient)); | |
} | |
start() { | |
// Start the webServer | |
this.webServer.start((err) => { | |
if (err) { | |
throw err; | |
} | |
console.log('Server running at:', this.webServer.info.uri); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment