From 3b12f7b964ac83b1a1b9948f329e6813bb457bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Beltr=C3=A1n=20B?= <99098993+jesusbeb@users.noreply.github.com> Date: Thu, 16 Jun 2022 12:59:57 -0500 Subject: [PATCH 1/3] Agregando un endpoint que regresa toda la lista de explorers filtrados por un stack --- lib/controllers/ExplorerController.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/controllers/ExplorerController.js b/lib/controllers/ExplorerController.js index 85590a6d..f969150d 100644 --- a/lib/controllers/ExplorerController.js +++ b/lib/controllers/ExplorerController.js @@ -21,6 +21,11 @@ class ExplorerController{ const explorers = Reader.readJsonFile("explorers.json"); return ExplorerService.getAmountOfExplorersByMission(explorers, mission); } + + static getExplorersByStack(mission){ + const explorers= Reader.readJsonFile("explorers.json"); + return ExplorerService.getExplorersByStack(explorers,mission); + } } module.exports = ExplorerController; From a88f02c6f01b6e921100e931da1673eae3542a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Beltr=C3=A1n=20B?= <99098993+jesusbeb@users.noreply.github.com> Date: Thu, 16 Jun 2022 13:00:58 -0500 Subject: [PATCH 2/3] Agregando un endpoint que regresa toda la lista de explorers filtrados por un stack --- lib/services/ExplorerService.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/services/ExplorerService.js b/lib/services/ExplorerService.js index 9fef9574..55e34130 100644 --- a/lib/services/ExplorerService.js +++ b/lib/services/ExplorerService.js @@ -15,7 +15,11 @@ class ExplorerService { const explorersUsernames = explorersByMission.map((explorer) => explorer.githubUsername); return explorersUsernames; } - + + static getExplorersByStack(explorers,mission){ + const explorerByStacks= explorers.filter((explorer) => explorer.stacks.includes(mission)); + return explorerByStacks; + } } module.exports = ExplorerService; From 1d1c51736acaaa9084a598e1e1fb2df8c4114c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Beltr=C3=A1n=20B?= <99098993+jesusbeb@users.noreply.github.com> Date: Thu, 16 Jun 2022 13:10:50 -0500 Subject: [PATCH 3/3] Agregando un endpoint que regresa toda la lista de explorers filtrados por un stack --- lib/server.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/server.js b/lib/server.js index 9860b437..45994d7a 100644 --- a/lib/server.js +++ b/lib/server.js @@ -32,6 +32,14 @@ app.get("/v1/fizzbuzz/:score", (request, response) => { response.json({score: score, trick: fizzbuzzTrick}); }); +// Crea un endpoint nuevo que regrese toda la lista de explorers filtrados por un stack +// localhost:3000/v1/explorers/stack/javascript. +app.get("/v1/explorers/stack/:mission", (req,res) => { + const mission= req.params.mission; + const ExplorersByStack = ExplorerController.getExplorersByStack(mission); + res.json(ExplorersByStack); +}); + app.listen(port, () => { console.log(`FizzBuzz API in localhost:${port}`); });