Skip to content

Instantly share code, notes, and snippets.

@Pyrolistical
Created November 7, 2017 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pyrolistical/2c3e4e3797140a20856ba6c681285878 to your computer and use it in GitHub Desktop.
Save Pyrolistical/2c3e4e3797140a20856ba6c681285878 to your computer and use it in GitHub Desktop.
Steven interview code
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.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>
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