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
11 changes: 5 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ module.exports = {
"browser": true,
"commonjs": true,
"es2021": true,
"jest": true
"jest": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": "latest"
},
"rules": {
"no-unused-vars": "off",
indent: ["error", 4],
"linebreak-style": ["error", "unix"],
indent: ["error",4],
"linebreak-style": ["error","unix"],
quotes: ["error", "double"],
semi: ["error", "always"]
semi: ["error","always"]
}
};
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
**/node_modules
**/package-lock.json
**/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");
const getListExplorersByStack = ExplorerService.getExplorersByStack(explorers,stack);
return getListExplorersByStack;
}
}

module.exports = ExplorerController;
7 changes: 7 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ 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 explorerListByStack = ExplorerController.getExplorersByStack(stack);
response.json(explorerListByStack);
});


app.listen(port, () => {
console.log(`FizzBuzz API in localhost:${port}`);
});
Expand Down
6 changes: 6 additions & 0 deletions lib/services/ExplorerService.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const Reader=require("./../utils/Reader");
class ExplorerService {

static filterByMission(explorers, mission){
Expand All @@ -16,6 +17,11 @@ class ExplorerService {
return explorersUsernames;
}

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

}

module.exports = ExplorerService;
Loading