Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FizzBuzz Contribution #169

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Run Tests in my project every push on GitHub

on: [push, pull_request]
on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run Jest
uses: stefanoeb/jest-action@1.0.3
uses: stefanoeb/jest-action@1.0.3
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
**/node_modules
**/package-lock.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(stacks){
const explorers = Reader.readJsonFile("explorers.json");
const listExplorersByStack = ExplorerService.getListExplorersByStack(explorers, stacks)
return listExplorersByStack
}
}

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

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

});

app.listen(port, () => {
console.log(`FizzBuzz API in localhost:${port}`);
});


4 changes: 4 additions & 0 deletions lib/services/ExplorerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class ExplorerService {
return explorersUsernames;
}

// Lista de explorers por stack
static getListExplorersByStack(explorers, stacks){
return explorers.filter(explorer => explorer.stacks.includes(stacks));
}
}

module.exports = ExplorerService;
Loading