working on code smells
continuous-integration/drone/push Build is passing Details

pull/9/head
Rémi REGNAULT 1 year ago
parent b4b6338ad5
commit 53b6798e48

@ -35,8 +35,6 @@ IngredientsController.get('/:id', async (req, res) => {
res.status(404).send('not found') res.status(404).send('not found')
} }
else { else {
const ingredient_ingredient = ingredient as Ingredient
res.status(200).json(ingredient) res.status(200).json(ingredient)
} }
} catch (error) { } catch (error) {

@ -33,7 +33,6 @@ RecipesController.get('/:id', async (req, res) => {
res.status(404).send('not found') res.status(404).send('not found')
} }
else { else {
const ingredient_ingredient = recipe as Recipe
res.status(200).json(recipe) res.status(200).json(recipe)
} }
} catch (error) { } catch (error) {

@ -21,8 +21,6 @@ StepsController.get('/:id', async (req, res) => {
res.status(404).send('not found') res.status(404).send('not found')
} }
else { else {
const steps_steps = steps as string[]
res.status(200).json(steps) res.status(200).json(steps)
} }
} catch (error) { } catch (error) {

@ -42,7 +42,7 @@ export class IngredientsGateway {
return ingredient return ingredient
} }
async findIngredientsForRecipe(id: Number): Promise<any> { async findIngredientsForRecipe(id: number): Promise<any> {
this.connection.connect(); this.connection.connect();
const query = { const query = {

@ -19,7 +19,7 @@ export class RecipeGateway {
const res = await this.connection.client.query('SELECT * FROM Recipes ORDER BY id'); const res = await this.connection.client.query('SELECT * FROM Recipes ORDER BY id');
const steps: string[] = []; const steps: string[] = [];
let recipes:Recipe[] = [] let recipes: Recipe[] = []
for (let key in res.rows) { for (let key in res.rows) {
const steps = await this.steps_gw.getForRecipes(Number(key)); const steps = await this.steps_gw.getForRecipes(Number(key));
@ -33,7 +33,7 @@ export class RecipeGateway {
return recipes return recipes
} }
async getById(id: Number) : Promise<Recipe | null>{ async getById(id: number) : Promise<Recipe | null>{
this.connection.connect() this.connection.connect()
const query = { const query = {
@ -47,8 +47,8 @@ export class RecipeGateway {
return null return null
} }
const steps = await this.steps_gw.getForRecipes(id) const steps = await this.steps_gw.getForRecipes(Number(id))
const ingredients = await this.ingredient_gw.findIngredientsForRecipe(id) const ingredients = await this.ingredient_gw.findIngredientsForRecipe(Number(id))
const recipe = new Recipe(Number(res.rows[0].id), const recipe = new Recipe(Number(res.rows[0].id),
res.rows[0].name, res.rows[0].name,
res.rows[0].description, res.rows[0].description,

@ -8,7 +8,7 @@ export class StepsGateway {
} }
async getForRecipes(id: Number): Promise<string[]> { async getForRecipes(id: number): Promise<string[]> {
this.connection.connect(); this.connection.connect();
const query = { const query = {

Loading…
Cancel
Save