This commit is contained in:
2021-06-21 15:14:16 +02:00
parent 1949f1522d
commit b58acdc0c9
9 changed files with 5 additions and 216 deletions

View File

@@ -1,14 +0,0 @@
const express = require("express");
const { handleError } = require("../services/services.js");
var router = express.Router();
router.post("/", async (req, res) => {
try {
console.log("test");
} catch (error) {
handleError(error, res);
}
});
module.exports = router;

View File

@@ -9,9 +9,7 @@ const {
changeLunchMenu,
changeLunchMenuSet,
fetchUser,
renewSubscription,
setRestaurantVisibility,
startTrial
} = require("../services/databaseServices.js");
const {
decodeAndSanitize,
@@ -184,36 +182,5 @@ router.post("/visibility", async (req, res) => {
}
})
// ACTIVATE SUBSCRIPTION
router.post("/subscription", async (req, res) => {
try {
const token = req.headers["x-auth-token"];
const user = validateUserToken(token);
await validateRestaurant(req.body.restaurantId);
/* const response = await initializePayment(
req.body.restaurantId,
req.body.userData,
req.body.type
); */
await renewSubscription(req.body.restaurantId, req.body.type);
res.sendStatus(200);
} catch (error) {
handleError(error, res);
}
});
// ACTIVATE TRIAL
router.post("/trial", async (req, res) => {
try {
const token = req.headers["x-auth-token"];
const user = validateUserToken(token);
await startTrial(req.body.restaurantId, user);
res.send("Okres próbny aktywowany.");
} catch (error) {
handleError(error, res);
}
})
module.exports = router;

View File

@@ -14,13 +14,11 @@ router.get("/", async (req, res) => {
const query = sanitizer.sanitize.keepUnicode(decodeURI(req.query.string));
validateSearch(query);
const regex = new RegExp(query, "i");
Restaurant.find(
{
$and: [
{ $or: [{ city: { $regex: regex } }, { name: { $regex: regex } }] },
{ $or: [{ hidden: false }, { hidden: { $exists: false } }] },
{ subscriptionActive: true },
{ $or: [{ hidden: false }, { hidden: { $exists: false } }] }
],
},
"_id name city adress type imgUrl workingHours description tags location"
@@ -76,8 +74,7 @@ router.get("/autocomplete/", (req, res) => {
Restaurant.find(
{ $and: [
{ $or: [{ city: { $regex: regex } }, { name: { $regex: regex } }] },
{ $or: [{ hidden: false }, { hidden: { $exists: false } }] },
{ subscriptionActive: true },
{ $or: [{ hidden: false }, { hidden: { $exists: false } }] }
], },
"name city",
(err, doc) => {