From 53b6798e48683488b68e33e94d83ed9ea295751d Mon Sep 17 00:00:00 2001 From: Remi REGNAULT Date: Wed, 29 Nov 2023 14:56:54 +0100 Subject: [PATCH] working on code smells --- API-Project/src/controllers/ingredients.controller.ts | 2 -- API-Project/src/controllers/recipes.controller.ts | 1 - API-Project/src/controllers/steps.controller.ts | 2 -- API-Project/src/gateways/ingredients.gateway.ts | 2 +- API-Project/src/gateways/recipe.gateway.ts | 8 ++++---- API-Project/src/gateways/steps.gateway.ts | 2 +- 6 files changed, 6 insertions(+), 11 deletions(-) diff --git a/API-Project/src/controllers/ingredients.controller.ts b/API-Project/src/controllers/ingredients.controller.ts index 4a99322..8889d5e 100644 --- a/API-Project/src/controllers/ingredients.controller.ts +++ b/API-Project/src/controllers/ingredients.controller.ts @@ -35,8 +35,6 @@ IngredientsController.get('/:id', async (req, res) => { res.status(404).send('not found') } else { - const ingredient_ingredient = ingredient as Ingredient - res.status(200).json(ingredient) } } catch (error) { diff --git a/API-Project/src/controllers/recipes.controller.ts b/API-Project/src/controllers/recipes.controller.ts index d636690..6c08fb1 100644 --- a/API-Project/src/controllers/recipes.controller.ts +++ b/API-Project/src/controllers/recipes.controller.ts @@ -33,7 +33,6 @@ RecipesController.get('/:id', async (req, res) => { res.status(404).send('not found') } else { - const ingredient_ingredient = recipe as Recipe res.status(200).json(recipe) } } catch (error) { diff --git a/API-Project/src/controllers/steps.controller.ts b/API-Project/src/controllers/steps.controller.ts index cf3612c..347896a 100644 --- a/API-Project/src/controllers/steps.controller.ts +++ b/API-Project/src/controllers/steps.controller.ts @@ -21,8 +21,6 @@ StepsController.get('/:id', async (req, res) => { res.status(404).send('not found') } else { - const steps_steps = steps as string[] - res.status(200).json(steps) } } catch (error) { diff --git a/API-Project/src/gateways/ingredients.gateway.ts b/API-Project/src/gateways/ingredients.gateway.ts index fcdeb63..6e282d8 100644 --- a/API-Project/src/gateways/ingredients.gateway.ts +++ b/API-Project/src/gateways/ingredients.gateway.ts @@ -42,7 +42,7 @@ export class IngredientsGateway { return ingredient } - async findIngredientsForRecipe(id: Number): Promise { + async findIngredientsForRecipe(id: number): Promise { this.connection.connect(); const query = { diff --git a/API-Project/src/gateways/recipe.gateway.ts b/API-Project/src/gateways/recipe.gateway.ts index df3b1c1..cb9087d 100644 --- a/API-Project/src/gateways/recipe.gateway.ts +++ b/API-Project/src/gateways/recipe.gateway.ts @@ -19,7 +19,7 @@ export class RecipeGateway { const res = await this.connection.client.query('SELECT * FROM Recipes ORDER BY id'); const steps: string[] = []; - let recipes:Recipe[] = [] + let recipes: Recipe[] = [] for (let key in res.rows) { const steps = await this.steps_gw.getForRecipes(Number(key)); @@ -33,7 +33,7 @@ export class RecipeGateway { return recipes } - async getById(id: Number) : Promise{ + async getById(id: number) : Promise{ this.connection.connect() const query = { @@ -47,8 +47,8 @@ export class RecipeGateway { return null } - const steps = await this.steps_gw.getForRecipes(id) - const ingredients = await this.ingredient_gw.findIngredientsForRecipe(id) + const steps = await this.steps_gw.getForRecipes(Number(id)) + const ingredients = await this.ingredient_gw.findIngredientsForRecipe(Number(id)) const recipe = new Recipe(Number(res.rows[0].id), res.rows[0].name, res.rows[0].description, diff --git a/API-Project/src/gateways/steps.gateway.ts b/API-Project/src/gateways/steps.gateway.ts index 99897ab..ddeae1b 100644 --- a/API-Project/src/gateways/steps.gateway.ts +++ b/API-Project/src/gateways/steps.gateway.ts @@ -8,7 +8,7 @@ export class StepsGateway { } - async getForRecipes(id: Number): Promise { + async getForRecipes(id: number): Promise { this.connection.connect(); const query = {