From a89a8246f07fc0b4e3eb30cc054f29e248981aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pablo=20Mu=C3=B1iz?= <98715775+devleon00@users.noreply.github.com> Date: Fri, 13 May 2022 08:26:15 -0500 Subject: [PATCH 1/3] Update ExplorerController.js --- lib/controllers/ExplorerController.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/controllers/ExplorerController.js b/lib/controllers/ExplorerController.js index 85590a6..7075a14 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 4a30d8b64e41afce67097e1fdad1ca5b8cab65c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pablo=20Mu=C3=B1iz?= <98715775+devleon00@users.noreply.github.com> Date: Fri, 13 May 2022 08:26:48 -0500 Subject: [PATCH 2/3] Update ExplorerService.js --- lib/services/ExplorerService.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/services/ExplorerService.js b/lib/services/ExplorerService.js index 9fef957..79d5e2a 100644 --- a/lib/services/ExplorerService.js +++ b/lib/services/ExplorerService.js @@ -15,7 +15,12 @@ class ExplorerService { const explorersUsernames = explorersByMission.map((explorer) => explorer.githubUsername); return explorersUsernames; } - + + static getExplorersByStack(explorers, mission) { + return explorers.filter((explorer) => { + return explorer.stacks.includes(mission); + }); + } } module.exports = ExplorerService; From 906a2421aab1df4c4dd33648e5cb9ad41b9ffd92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pablo=20Mu=C3=B1iz?= <98715775+devleon00@users.noreply.github.com> Date: Fri, 13 May 2022 08:27:16 -0500 Subject: [PATCH 3/3] Update server.js --- lib/server.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/server.js b/lib/server.js index 9860b43..e9379c2 100644 --- a/lib/server.js +++ b/lib/server.js @@ -32,6 +32,11 @@ app.get("/v1/fizzbuzz/:score", (request, response) => { response.json({score: score, trick: fizzbuzzTrick}); }); +app.get("/v1/explorers/stack/:stack", (request, response) => { + const stack = request.params.stack; + response.json(ExplorerController.getExplorersByStack(stack)); +}); + app.listen(port, () => { console.log(`FizzBuzz API in localhost:${port}`); });