From 047f2660f2c41a49ea2ec499cb47087942d09e2b Mon Sep 17 00:00:00 2001 From: Jonasz Bigda Date: Fri, 5 Feb 2021 19:57:19 +0100 Subject: [PATCH] fixes --- services/dataPrepServices.js | 26 +++++++++++++------------- services/validations.js | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/services/dataPrepServices.js b/services/dataPrepServices.js index 57daa55..14fb1f1 100644 --- a/services/dataPrepServices.js +++ b/services/dataPrepServices.js @@ -1,5 +1,4 @@ const { hashPass, newError, saveImage } = require("./services.js"); -const sanitizer = require("string-sanitizer"); const mongoose = require("mongoose"); const Dish = require("../models/dish.js"); const User = require("../models/users.js"); @@ -53,9 +52,9 @@ async function createRestaurant(request, oldRestaurant) { const img = await handleImageUpdate(request); const restaurant = new Restaurant({ _id: new mongoose.Types.ObjectId(), - name: sanitizer.sanitize.keepUnicode(request.name), - city: sanitizer.sanitize.keepUnicode(request.city), - adress: sanitizer.sanitize.keepUnicode(request.adress), + name: request.name, + city: request.city, + adress: request.adress, location: { type: "Point", coordinates: request.coordinates, @@ -65,7 +64,7 @@ async function createRestaurant(request, oldRestaurant) { imgUrl: img, workingHours: request.workingHours, lunchHours: request.lunchHours, - description: sanitizer.sanitize.keepUnicode(request.description), + description: request.description, tags: request.tags, links: request.links, phone: request.phone, @@ -75,10 +74,11 @@ async function createRestaurant(request, oldRestaurant) { } else { const img = await handleImageUpdate(request, oldRestaurant); const restaurant = new Restaurant({ - name: sanitizer.sanitize.keepUnicode(request.name), - city: sanitizer.sanitize.keepUnicode(request.city), + _id: oldRestaurant._id, + name: request.name, + city: request.city, dishes: oldRestaurant.dishes, - adress: sanitizer.sanitize.keepUnicode(request.adress), + adress: request.adress, location: { type: "Point", coordinates: request.coordinates, @@ -90,7 +90,7 @@ async function createRestaurant(request, oldRestaurant) { lunchHours: request.lunchHours, lunchMenu: oldRestaurant.lunchMenu, categories: oldRestaurant.categories, - description: sanitizer.sanitize.keepUnicode(request.description), + description: request.description, tags: request.tags, links: request.links, phone: request.phone, @@ -129,10 +129,10 @@ async function createDish(dish, restaurantId, oldDish) { const newDish = new Dish({ _id: new mongoose.Types.ObjectId(), restaurantId: restaurantId, - name: sanitizer.sanitize.keepUnicode(dish.name), + name: dish.name, category: dish.category, prices: dish.prices, - notes: sanitizer.sanitize.keepUnicode(dish.notes), + notes: dish.notes, imgUrl: img, weight: dish.weight, allergens: dish.allergens, @@ -147,10 +147,10 @@ async function createDish(dish, restaurantId, oldDish) { const img = await handleImageUpdate(dish, oldDish); const newDish = new Dish({ restaurantId: oldDish.restaurantId, - name: sanitizer.sanitize.keepUnicode(dish.name), + name: dish.name, category: dish.category, prices: dish.prices, - notes: sanitizer.sanitize.keepUnicode(dish.notes), + notes: dish.notes, imgUrl: img, weight: dish.weight, allergens: dish.allergens, diff --git a/services/validations.js b/services/validations.js index 05a1753..ef65d76 100644 --- a/services/validations.js +++ b/services/validations.js @@ -48,7 +48,7 @@ const validateRestaurantData = function(requestBody){ const city = validator.isLength(requestBody.city, { max: 64 }) const adress = validator.isLength(requestBody.adress, { max: 64 }) const type = validator.isLength(requestBody.type, { max: 64 }) - const description = true; + let description = true; if(requestBody.description){ description = validator.isLength(requestBody.description, { max: 400 }) }