Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
package.json
6 changes: 6 additions & 0 deletions lib/controllers/ExplorerController.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class ExplorerController{
const explorers = Reader.readJsonFile("explorers.json");
return ExplorerService.getAmountOfExplorersByMission(explorers, mission);
}

static getExplorersByStack(stack){
const explorers = Reader.readJsonFile("explorers.json");
return ExplorerService.getExplorersByStack(explorers,stack);
}

}

module.exports = ExplorerController;
6 changes: 6 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ app.get("/v1/fizzbuzz/:score", (request, response) => {
response.json({score: score, trick: fizzbuzzTrick});
});

app.get("/v1/explorers/stack/:stacks", (request, response) => {
const stack = request.params.stacks;
const explorerList = ExplorerController.getExplorersByStack(stack);
response.json(explorerList);
});

app.listen(port, () => {
console.log(`FizzBuzz API in localhost:${port}`);
});
Expand Down
5 changes: 5 additions & 0 deletions lib/services/ExplorerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ class ExplorerService {
return explorersUsernames;
}

static getExplorersByStack(explorers,stack){
const explorersList = explorers.filter((explorer) => explorer.stacks.includes(stack));
return explorersList;
}

}

module.exports = ExplorerService;
Loading