validation 1

This commit is contained in:
2021-01-30 16:31:52 +01:00
parent dc7a92f22a
commit 3b7ca3ccb3
3 changed files with 81 additions and 22 deletions

View File

@@ -23,6 +23,7 @@ const {
checkPassword,
} = require("../services/services.js");
const Restaurant = require("../models/restaurant.js");
const { validateRestaurant } = require("../services/validations.js");
var router = express.Router();
@@ -44,6 +45,7 @@ router.post("/", async (req, res) => {
try {
const token = req.headers["x-auth-token"];
const user = validateUserToken(token);
validateRestaurant(req.body);
const restaurant = await createRestaurant(req.body).catch((err) => {
throw newError("Nie udało się zapisać zdjęcia.", 500);
});