diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index b58b603..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml deleted file mode 100644 index 7ba3bc0..0000000 --- a/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index 79ee123..0000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/cyberchef.iml b/.idea/cyberchef.iml deleted file mode 100644 index 0c8867d..0000000 --- a/.idea/cyberchef.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 34d5e16..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/database/repositories/category.js b/src/database/repositories/category.js deleted file mode 100644 index 5e24bb2..0000000 --- a/src/database/repositories/category.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -export default class CategoryRepository { - constructor(prisma) { - this.prisma = prisma; - } - - async add(name) { - try { - await this.prisma.categories.create({ - data: { - name, - }, - }); - return true; - } catch (error) { - console.error(error); - return false; - } - } - - async findAll() { - return await this.prisma.categories.findMany(); //returns an array of all categories - } -} diff --git a/src/database/repositories/recipe.js b/src/database/repositories/recipe.js deleted file mode 100644 index f465112..0000000 --- a/src/database/repositories/recipe.js +++ /dev/null @@ -1,67 +0,0 @@ -'use strict'; - -export default class RecipeRepository { - constructor(prisma) { - this.prisma = prisma; - } - - async add(recipeData) { - try { - await this.prisma.recipes.create({ - data: { - name: recipeData.name, - category_id: parseInt(recipeData.categoryId), - products: recipeData.products, - description: recipeData.description, - image_link: recipeData.imageLink, - }, - }); - return true; - } catch (error) { - console.error(error); - return false; - } - } - - async find(recipeId) { - return await this.prisma.recipes.findUnique({ - where: { - id: parseInt(recipeId), - }, - }); - } - - async findAll() { - return await this.prisma.recipes.findMany(); - } - - async delete(recipeId) { - try { - const deleteFavRecipes = this.prisma.favourite_recipes.deleteMany({ - where: { - recipe_id: parseInt(recipeId), - }, - }); - const deleteRecipe = this.prisma.recipes.delete({ - where: { - id: parseInt(recipeId), - }, - }); - await this.prisma.$transaction([deleteFavRecipes, deleteRecipe]); - return true; - } catch (error) { - console.error(error); - return false; - } - } - - async search(str) { - return await this.prisma.recipes.findMany({ - where: { - name: { - contains: str, - }, - }, - }); - } -} diff --git a/src/database/repositories/user.js b/src/database/repositories/user.js deleted file mode 100644 index 246c549..0000000 --- a/src/database/repositories/user.js +++ /dev/null @@ -1,71 +0,0 @@ -'use strict'; - -export default class UserRepository { - constructor(prisma) { - this.prisma = prisma; - } - - async add(userData) { - try { - await this.prisma.users.create({ - data: { - email: userData.email, - username: userData.username, - password: userData.passwordhash, - }, - }); - return true; - } catch (error) { - console.error(error); - return false; - } - } - - async find(username) { - return await this.prisma.users.findUnique({ - where: { - username, - }, - }); //returns user object - } - - async findRecipes(userId) { - let favRecipes = await this.prisma.favourite_recipes.findMany({ - where: { - user_id: parseInt(userId), - }, - select: { - recipe_id: true, - }, - }); - favRecipes = favRecipes.map(el => el.recipe_id); - return favRecipes; //returns an array user favourite recipes ids - } - - async addRecipe(recipeData) { - const favRecipe = await this.prisma.favourite_recipes.create({ - data: { - user_id: recipeData.userId, - recipe_id: recipeData.recipeId, - }, - }); - if (typeof favRecipe !== 'undefined' && favRecipe) { - return true; - } - } - - async deleteRecipe(recipeData) { - try { - await this.prisma.favourite_recipes.deleteMany({ - where: { - user_id: recipeData.userId, - recipe_id: recipeData.recipeId, - }, - }); - return true; - } catch (error) { - console.error(error); - return false; - } - } -}