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
7 changes: 7 additions & 0 deletions lib/controllers/ExplorerController.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ class ExplorerController{
const explorers = Reader.readJsonFile("explorers.json");
return ExplorerService.getAmountOfExplorersByMission(explorers, mission);
}

static explorersbystack(stack){
const path = "./explorers/explorers.json";
const explorers = Reader.readJSONFile(path);
const explorersbyStack = ExplorerService.getExplorersByStack(explorers, stack);
return explorersbyStack;
}
}

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/:stack", (request, response) => {
const stack = request.params.stack;
const explorers_with_that_stack = ExplorerController.explorersbystack(stack);
response.json({stack: request.params.stack, explorers: explorers_with_that_stack});
});

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 @@ -15,6 +15,11 @@ class ExplorerService {
const explorersUsernames = explorersByMission.map((explorer) => explorer.githubUsername);
return explorersUsernames;
}

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

}

Expand Down