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

Creación de endpoint lista explorers por stack #156

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

OlafRuv
Copy link

@OlafRuv OlafRuv commented May 13, 2022

Pull request de Creación de endpoint lista explorers por stack

Creación de un endpoint nuevo que regrese toda la lista de explorers filtrados por un stack.

Ejemplo de url: localhost:3000/v1/explorers/stack/javascript.
Response: Todos los explorers que tengan en stack el valor recibido en la url.

Estos son los pasos que seguí para cumplir con el requerimiento:

  • Creamos el método estático getExplorersbyStack en el ExplorerService
static getExplorersbyStack(explorers,stack){
        const explorersByStack = explorers.filter((explorer) => explorer.stacks.includes(stack));
        return explorersByStack;
}
  • Creamos el test para el nuevo método de getExplorersbyStack
test("Requerimiento 2: Obtener todos los explorers con cierto stack", () => {
        const explorers = [{stacks: ["javascript","reasonML","elm"]}];
        const explorersWithStack = ExplorerService.getExplorersbyStack(explorers, "reasonML");
        expect(explorersWithStack.length).toBe(1);
    });
  • Creamos el método estático getExplorersByStack en ExplorerController
static getExplorersByStack(stack){
        const explorers = Reader.readJsonFile("explorers.json");
        return ExplorerService.getExplorersbyStack(explorers, stack);
    }
  • Creamos el endpoint /v1/explorers/stack/javascript en la API para obtener los explorers por stack
app.get("/v1/explorers/stack/:stack", (request, response) => {
    const stack = request.params.stack;
    const explorersByStack = ExplorerController.getExplorersByStack(stack);
    response.json({mission: request.params.mission, explorers: explorersByStack});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant