fixes
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
const { hashPass, newError, saveImage } = require("./services.js");
|
const { hashPass, newError, saveImage } = require("./services.js");
|
||||||
const sanitizer = require("string-sanitizer");
|
|
||||||
const mongoose = require("mongoose");
|
const mongoose = require("mongoose");
|
||||||
const Dish = require("../models/dish.js");
|
const Dish = require("../models/dish.js");
|
||||||
const User = require("../models/users.js");
|
const User = require("../models/users.js");
|
||||||
@@ -53,9 +52,9 @@ async function createRestaurant(request, oldRestaurant) {
|
|||||||
const img = await handleImageUpdate(request);
|
const img = await handleImageUpdate(request);
|
||||||
const restaurant = new Restaurant({
|
const restaurant = new Restaurant({
|
||||||
_id: new mongoose.Types.ObjectId(),
|
_id: new mongoose.Types.ObjectId(),
|
||||||
name: sanitizer.sanitize.keepUnicode(request.name),
|
name: request.name,
|
||||||
city: sanitizer.sanitize.keepUnicode(request.city),
|
city: request.city,
|
||||||
adress: sanitizer.sanitize.keepUnicode(request.adress),
|
adress: request.adress,
|
||||||
location: {
|
location: {
|
||||||
type: "Point",
|
type: "Point",
|
||||||
coordinates: request.coordinates,
|
coordinates: request.coordinates,
|
||||||
@@ -65,7 +64,7 @@ async function createRestaurant(request, oldRestaurant) {
|
|||||||
imgUrl: img,
|
imgUrl: img,
|
||||||
workingHours: request.workingHours,
|
workingHours: request.workingHours,
|
||||||
lunchHours: request.lunchHours,
|
lunchHours: request.lunchHours,
|
||||||
description: sanitizer.sanitize.keepUnicode(request.description),
|
description: request.description,
|
||||||
tags: request.tags,
|
tags: request.tags,
|
||||||
links: request.links,
|
links: request.links,
|
||||||
phone: request.phone,
|
phone: request.phone,
|
||||||
@@ -75,10 +74,11 @@ async function createRestaurant(request, oldRestaurant) {
|
|||||||
} else {
|
} else {
|
||||||
const img = await handleImageUpdate(request, oldRestaurant);
|
const img = await handleImageUpdate(request, oldRestaurant);
|
||||||
const restaurant = new Restaurant({
|
const restaurant = new Restaurant({
|
||||||
name: sanitizer.sanitize.keepUnicode(request.name),
|
_id: oldRestaurant._id,
|
||||||
city: sanitizer.sanitize.keepUnicode(request.city),
|
name: request.name,
|
||||||
|
city: request.city,
|
||||||
dishes: oldRestaurant.dishes,
|
dishes: oldRestaurant.dishes,
|
||||||
adress: sanitizer.sanitize.keepUnicode(request.adress),
|
adress: request.adress,
|
||||||
location: {
|
location: {
|
||||||
type: "Point",
|
type: "Point",
|
||||||
coordinates: request.coordinates,
|
coordinates: request.coordinates,
|
||||||
@@ -90,7 +90,7 @@ async function createRestaurant(request, oldRestaurant) {
|
|||||||
lunchHours: request.lunchHours,
|
lunchHours: request.lunchHours,
|
||||||
lunchMenu: oldRestaurant.lunchMenu,
|
lunchMenu: oldRestaurant.lunchMenu,
|
||||||
categories: oldRestaurant.categories,
|
categories: oldRestaurant.categories,
|
||||||
description: sanitizer.sanitize.keepUnicode(request.description),
|
description: request.description,
|
||||||
tags: request.tags,
|
tags: request.tags,
|
||||||
links: request.links,
|
links: request.links,
|
||||||
phone: request.phone,
|
phone: request.phone,
|
||||||
@@ -129,10 +129,10 @@ async function createDish(dish, restaurantId, oldDish) {
|
|||||||
const newDish = new Dish({
|
const newDish = new Dish({
|
||||||
_id: new mongoose.Types.ObjectId(),
|
_id: new mongoose.Types.ObjectId(),
|
||||||
restaurantId: restaurantId,
|
restaurantId: restaurantId,
|
||||||
name: sanitizer.sanitize.keepUnicode(dish.name),
|
name: dish.name,
|
||||||
category: dish.category,
|
category: dish.category,
|
||||||
prices: dish.prices,
|
prices: dish.prices,
|
||||||
notes: sanitizer.sanitize.keepUnicode(dish.notes),
|
notes: dish.notes,
|
||||||
imgUrl: img,
|
imgUrl: img,
|
||||||
weight: dish.weight,
|
weight: dish.weight,
|
||||||
allergens: dish.allergens,
|
allergens: dish.allergens,
|
||||||
@@ -147,10 +147,10 @@ async function createDish(dish, restaurantId, oldDish) {
|
|||||||
const img = await handleImageUpdate(dish, oldDish);
|
const img = await handleImageUpdate(dish, oldDish);
|
||||||
const newDish = new Dish({
|
const newDish = new Dish({
|
||||||
restaurantId: oldDish.restaurantId,
|
restaurantId: oldDish.restaurantId,
|
||||||
name: sanitizer.sanitize.keepUnicode(dish.name),
|
name: dish.name,
|
||||||
category: dish.category,
|
category: dish.category,
|
||||||
prices: dish.prices,
|
prices: dish.prices,
|
||||||
notes: sanitizer.sanitize.keepUnicode(dish.notes),
|
notes: dish.notes,
|
||||||
imgUrl: img,
|
imgUrl: img,
|
||||||
weight: dish.weight,
|
weight: dish.weight,
|
||||||
allergens: dish.allergens,
|
allergens: dish.allergens,
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ const validateRestaurantData = function(requestBody){
|
|||||||
const city = validator.isLength(requestBody.city, { max: 64 })
|
const city = validator.isLength(requestBody.city, { max: 64 })
|
||||||
const adress = validator.isLength(requestBody.adress, { max: 64 })
|
const adress = validator.isLength(requestBody.adress, { max: 64 })
|
||||||
const type = validator.isLength(requestBody.type, { max: 64 })
|
const type = validator.isLength(requestBody.type, { max: 64 })
|
||||||
const description = true;
|
let description = true;
|
||||||
if(requestBody.description){
|
if(requestBody.description){
|
||||||
description = validator.isLength(requestBody.description, { max: 400 })
|
description = validator.isLength(requestBody.description, { max: 400 })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user