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
function pokemonControllerFactory(pokemonDbLayer){ | |
let pokemonController = {}; | |
function getPokemonProfile(pokemonId){ | |
let pokemonObj = pokemon_db_layer.findById(pokemonId); | |
return { | |
name: pokemonObj ? pokemonObj.name : "", |
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
let pokemonDb = require('./pokemon_db_layer'); | |
let pokemonControllerFactory = require('./pokemon_controller'); | |
let pokemonController = pokemonControllerFactory(pokemonDb); |
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
let db_driver = require('db_driver'); | |
function findById(pokemonId){ | |
return db_driver.Pokemon.find({id: pokemonId}); | |
} | |
module.exports ={ | |
findById: findById | |
}; |
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
let pokemon_db_layer = require('./pokemon_db_layer'); | |
function getPokemonProfile(pokemonId){ | |
let pokemonObj = pokemon_db_layer.findById(pokemonId); | |
return { | |
name: pokemonObj ? pokemonObj.name : "", | |
level: pokemonObj ? pokemonObj.level : "" | |
}; |