Skip to content

Instantly share code, notes, and snippets.

@priyankvex2
Last active June 24, 2019 13:19
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 priyankvex2/589e87afb3d328c0f43f8c3934da874e to your computer and use it in GitHub Desktop.
Save priyankvex2/589e87afb3d328c0f43f8c3934da874e to your computer and use it in GitHub Desktop.
Pokemon controller DI
function pokemonControllerFactory(pokemonDbLayer){
let pokemonController = {};
function getPokemonProfile(pokemonId){
let pokemonObj = pokemon_db_layer.findById(pokemonId);
return {
name: pokemonObj ? pokemonObj.name : "",
level: pokemonObj ? pokemonObj.level : ""
};
}
pokemonController.getPokemonProfile = getPokemonProfile;
return pokemonController;
}
module.exports = {
pokemonController: pokemonControllerFactory
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment