Compare commits

..
Author SHA1 Message Date
237x237 bdc8d9a8e0 feat: add get master with orders
platform/multy-stub/pipeline/head There was a failure building this commit
2025-01-26 00:41:48 +03:00
307 changed files with 320 additions and 507 deletions

No files matched your search

+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "multi-stub", "name": "multi-stub",
"version": "1.2.0", "version": "1.1.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "multi-stub", "name": "multi-stub",
"version": "1.2.0", "version": "1.1.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"axios": "^1.7.9", "axios": "^1.7.9",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "multi-stub", "name": "multi-stub",
"version": "1.2.0", "version": "1.1.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
+1 -1
View File
@@ -88,7 +88,7 @@ app.use("/dry-wash", require("./routers/dry-wash"))
app.use("/freetracker", require("./routers/freetracker")) app.use("/freetracker", require("./routers/freetracker"))
app.use("/dhs-testing", require("./routers/dhs-testing")) app.use("/dhs-testing", require("./routers/dhs-testing"))
app.use("/gamehub", require("./routers/gamehub")) app.use("/gamehub", require("./routers/gamehub"))
app.use("/esc", require("./routers/esc"))
app.use(require("./error")) app.use(require("./error"))
+29 -5
View File
@@ -1,16 +1,40 @@
const router = require('express').Router() const router = require('express').Router()
const {MasterModel} = require('./model/master') const {MasterModel} = require('./model/master')
const mongoose = require("mongoose") const mongoose = require("mongoose")
const {OrderModel} = require("./model/order")
router.get('/masters', async (req, res,next) => { router.get("/masters", async (req, res, next) => {
try { try {
const master = await MasterModel.find({}) const masters = await MasterModel.find({});
res.status(200).send({success: true, body: master}) const orders = await OrderModel.find({});
const mastersWithOrders = masters.map((master) => {
const masterOrders = orders.filter((order) => {
return (
order?.master && order.master.toString() === master._id.toString()
);
});
const schedule = masterOrders.map((order) => ({
id: order._id,
startWashTime: order.startWashTime,
endWashTime: order.endWashTime,
}));
return {
id: master._id,
name: master.name,
schedule: schedule,
phone: master.phone,
};
});
res.status(200).send({ success: true, body: mastersWithOrders });
} catch (error) { } catch (error) {
next(error) next(error);
} }
}) });
router.delete('/masters/:id', async (req, res,next) => { router.delete('/masters/:id', async (req, res,next) => {
const { id } = req.params; const { id } = req.params;
-12
View File
@@ -1,12 +0,0 @@
const router = require("express").Router();
router.get('/game-links', (request, response) => {
response.send(require('./json/game-links/success.json'))
})
router.get('/4u2k-links', (request, response) => {
response.send(require('./json/4u2k-links/success.json'))
})
;
module.exports = router;
@@ -1,31 +0,0 @@
{
"data":[
{
"type": "video",
"links": {
"l1": "https://www.youtube.com/embed/DsQMLrPdLf8?si=l9X57nHqaSYlxDFf",
"l2": "https://www.youtube.com/embed/Dk8AAU_UdVk?si=N8NdYMUCfawdsJGE",
"l3": "https://www.youtube.com/embed/HKfDfWrCwEA?si=qPugjiKR8V9eZ-yG",
"l4": "https://www.youtube.com/embed/tD-6xHAHrQ4?si=ZFe41gSK8d5gqahW"
}
},
{
"type": "podcast",
"links": {
"l1": "https://www.youtube.com/embed/RtVs87Nd1MQ?si=i4giUCtbp4Ouqv2W",
"l2": "https://www.youtube.com/embed/DfTU5LA_kw8?si=m7fI5Ie9yIGDFCrU",
"l3": "https://www.youtube.com/embed/Sp-1fX1Q15I?si=xyealVly9IBMW7Xi",
"l4": "https://www.youtube.com/embed/rLYFJYfluRs?si=MjW1beQ-Q9-TAehF"
}
},
{
"type": "entertainment",
"links": {
"l1": "https://www.youtube.com/embed/DiuuglRCchQ?si=8wTVXKbV-mbHuSjW",
"l2": "https://www.youtube.com/embed/zmZcIX5PEyo?si=Hbrv32kl0fqcmtV9",
"l3": "https://www.youtube.com/embed/Te-TZUjmzFQ?si=fNG16eruoFEY2KNq",
"l4": "https://www.youtube.com/embed/si-MQ5qg3zE?si=67mfO6gV80n1ULqo"
}
}
]
}
@@ -1,20 +0,0 @@
{
"data":[
{
"title": "ABC",
"description": "Мой брат Колян сбацал про меня байку на англицком и несколько фишек кинул для шухера. Англицкий ты вроде знаешь, впряжешься за меня, а?",
"link": "https://www.oxfordonlineenglish.com/english-level-test/reading"
},
{
"title": "Алё, меня слышно?",
"description": "Мой кент на мобилу текст записал с иностранкой. Понимаешь, о чём тут говорят?",
"link": "https://test-english.com/listening/"
},
{
"title": "Анонимное тестирование",
"description": "Ты язык-то нормально знаешь? Проверься, никто угарать не будет",
"link": "https://www.ego4u.com/en/cram-up/tests"
}
]
}
+6 -171
View File
@@ -8,44 +8,22 @@ router.get("/update-like", (request, response) => {
response.send(require("./json/gamepage/success.json")); response.send(require("./json/gamepage/success.json"));
}); });
router.get("/add-to-cart", (request, response) => {
response.send(require("./json/home-page-data/games-in-cart.json"));
});
router.get("/categories", (request, response) => { router.get("/categories", (request, response) => {
response.send(require("./json/home-page-data/all-games.json")); response.send(require("./json/categories/success.json"));
}); });
router.get("/favourites", (request, response) => {
response.send(require("./json/home-page-data/all-games.json"));
});
// router.get("/shopping-cart", (request, response) => {
// response.send(require("./json/shopping-cart/success.json"));
// });
router.get("/shopping-cart", (request, response) => { router.get("/shopping-cart", (request, response) => {
response.send(require("./json/home-page-data/games-in-cart.json")); response.send(require("./json/shopping-cart/success.json"));
}); });
// Добавляем поддержку разных ответов для /home router.get("/home", (request, response) => {
router.get("/home", (req, res) => { response.send(require("./json/home-page-data/success.json"));
if (stubs.home === "success") {
res.send(require("./json/home-page-data/success.json"));
} else if (stubs.home === "empty") {
res.send({ data: [] }); // Отправляем пустой массив
} else {
res.status(500).json({ success: false, message: "Server error" });
}
}); });
router.get("/all-games", (request, response) => { router.get("/all-games", (request, response) => {
response.send(require("./json/home-page-data/all-games.json")); response.send(require("./json/home-page-data/all-games.json"));
}); });
const stubs = {
home: "success",
};
// // Маршрут для обновления лайков // // Маршрут для обновления лайков
// router.post("/update-like", (request, response) => { // router.post("/update-like", (request, response) => {
@@ -60,6 +38,7 @@ const stubs = {
// }); // });
// }); // });
const fs = require("fs").promises; const fs = require("fs").promises;
const path = require("path"); const path = require("path");
@@ -70,7 +49,7 @@ const commentsFilePath = path.join(__dirname, "./json/gamepage/success.json");
async function readComments() { async function readComments() {
const data = await fs.readFile(commentsFilePath, "utf-8"); const data = await fs.readFile(commentsFilePath, "utf-8");
const parsedData = JSON.parse(data); const parsedData = JSON.parse(data);
console.log("Прочитанные данные:", parsedData); // Логируем полученные данные console.log("Прочитанные данные:", parsedData); // Логируем полученные данные
return parsedData; return parsedData;
} }
// Write to JSON file // Write to JSON file
@@ -109,149 +88,5 @@ router.post("/update-like", async (req, res) => {
} }
}); });
// Путь к JSON-файлу с корзиной
const cartFilePath = path.join(
__dirname,
"./json/home-page-data/games-in-cart.json"
);
// Функция для чтения JSON-файла
async function readCart() {
const data = await fs.readFile(cartFilePath, "utf-8");
return JSON.parse(data);
}
// Функция для записи в JSON-файл
async function writeCart(data) {
await fs.writeFile(cartFilePath, JSON.stringify(data, null, 2), "utf-8");
}
// Маршрут для добавления/удаления товара в корзине
router.post("/add-to-cart", async (req, res) => {
const { id, action } = req.body;
// Проверка наличия id и action
if (id === undefined || action === undefined) {
return res
.status(400)
.json({ success: false, message: "Invalid id or action" });
}
try {
const cartData = await readCart();
let ids = cartData.data.ids;
if (action === "add") {
// Если action "add", добавляем товар, если его нет в корзине
if (!ids?.includes(id)) {
ids.push(id);
}
} else if (action === "remove") {
// Если action "remove", удаляем товар, если он есть в корзине
if (ids?.includes(id)) {
ids = ids.filter((item) => item !== id);
}
} else {
// Если action невалиден
return res
.status(400)
.json({ success: false, message: "Invalid action" });
}
// Записываем обновленные данные обратно в файл
cartData.data.ids = ids;
await writeCart(cartData);
res.status(200).json({
success: true,
message: "Cart updated successfully",
data: cartData.data, // Возвращаем обновленные данные
});
} catch (error) {
console.error("Error updating cart:", error);
res.status(500).json({ success: false, message: "Server error" });
}
});
module.exports = router; module.exports = router;
const createElement = (key, value, buttonTitle, basePath) => `
<label>
<input name="${key}" type="radio" ${
stubs[key] === value ? "checked" : ""
} onclick="fetch('${basePath}/admin/set/${key}/${value}')"/>
${buttonTitle || value}
</label>
`;
router.get("/admin/home", (request, response) => {
const basePath = request.baseUrl; // Получаем базовый путь маршрутизатора
response.send(`
<div>
<fieldset>
<legend>Настройка данных для /home</legend>
${createElement("home", "success", "Отдать успешный ответ", basePath)}
${createElement("home", "empty", "Отдать пустой массив", basePath)}
${createElement("home", "error", "Отдать ошибку", basePath)}
</fieldset>
</div>
`);
});
router.get("/admin/game-page", (request, response) => {
response.send(`
<div>
<fieldset>
<legend>Настройка данных для /game-page</legend>
${createElement(
"game-page",
"success",
"Отдать успешный ответ"
)}
${createElement("game-page", "empty", "Отдать пустой массив")}
${createElement("game-page", "error", "Отдать ошибку")}
</fieldset>
</div>
`);
});
router.get("/admin/categories", (request, response) => {
response.send(`
<div>
<fieldset>
<legend>Настройка данных для /categories</legend>
${createElement(
"categories",
"success",
"Отдать успешный ответ"
)}
${createElement("categories", "empty", "Отдать пустой массив")}
${createElement("categories", "error", "Отдать ошибку")}
</fieldset>
</div>
`);
});
router.get("/admin/favourites", (request, response) => {
response.send(`
<div>
<fieldset>
<legend>Настройка данных для /favourites</legend>
${createElement(
"favourites",
"success",
"Отдать успешный ответ"
)}
${createElement("favourites", "empty", "Отдать пустой массив")}
${createElement("favourites", "error", "Отдать ошибку")}
</fieldset>
</div>
`);
});
router.get("/admin/set/:key/:value", (request, response) => {
const { key, value } = request.params;
stubs[key] = value;
response.send("Настройки обновлены!");
});
@@ -0,0 +1,186 @@
{
"success": true,
"data": {
"games1": [
{
"id": 1,
"title": "How to Survive",
"price": 259,
"old_price": 500,
"image": "sales_game1",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
},
{
"id": 2,
"title": "Red Solstice 2 Survivors",
"price": 561,
"image": "sales_game2",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
},
{
"id": 3,
"title": "Sons Of The Forests",
"price": 820,
"old_price": 1100,
"image": "new_game2",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
},
{
"id": 4,
"title": "The Witcher 3: Wild Hunt",
"price": 990,
"old_price": 1200,
"image": "leaders_game4",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
},
{
"id": 5,
"title": "Atomic Heart",
"price": 1200,
"old_price": 2500,
"image": "leaders_game5",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
},
{
"id": 6,
"title": "Crab Game",
"price": 600,
"old_price": 890,
"image": "leaders_game6",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
}
],
"games2": [
{
"id": 7,
"title": "Alpha League",
"price": 299,
"image": "new_game1",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
},
{
"id": 8,
"title": "Sons Of The Forests",
"price": 820,
"old_price": 1100,
"image": "new_game2",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
},
{
"id": 9,
"title": "Pacific Drives",
"price": 1799,
"image": "new_game3",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
},
{
"id": 4,
"title": "The Witcher 3: Wild Hunt",
"price": 990,
"old_price": 1200,
"image": "leaders_game4",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
},
{
"id": 5,
"title": "Atomic Heart",
"price": 1200,
"old_price": 2500,
"image": "leaders_game5",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
},
{
"id": 6,
"title": "Crab Game",
"price": 600,
"old_price": 890,
"image": "leaders_game6",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
}
],
"games3": [
{
"id": 10,
"title": "Elden Ring",
"price": 3295,
"old_price": 3599,
"image": "leaders_game2",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
},
{
"id": 11,
"title": "Counter-Strike 2",
"price": 479,
"image": "leaders_game1",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
},
{
"id": 12,
"title": "PUBG: BATTLEGROUNDS",
"price": 199,
"image": "leaders_game3",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
},
{
"id": 4,
"title": "The Witcher 3: Wild Hunt",
"price": 990,
"old_price": 1200,
"image": "leaders_game4",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
},
{
"id": 5,
"title": "Atomic Heart",
"price": 1200,
"old_price": 2500,
"image": "leaders_game5",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
},
{
"id": 6,
"title": "Crab Game",
"price": 600,
"old_price": 890,
"image": "leaders_game6",
"os": "windows",
"fav1": "star1",
"fav2": "star2"
}
]
}
}
@@ -5,28 +5,28 @@
{ {
"username": "Пользователь1", "username": "Пользователь1",
"text": "Текст комментария 1", "text": "Текст комментария 1",
"likes": 13, "likes": 9,
"rating": 8, "rating": 8,
"date": "2025-03-01T10:00:00Z" "date": "2025-03-01T10:00:00Z"
}, },
{ {
"username": "Пользователь2", "username": "Пользователь2",
"text": "Текст комментария 2", "text": "Текст комментария 2",
"likes": 10, "likes": 7,
"rating": 7, "rating": 7,
"date": "2025-01-01T10:00:00Z" "date": "2025-01-01T10:00:00Z"
}, },
{ {
"username": "Пользователь3", "username": "Пользователь3",
"text": "Текст комментария 3", "text": "Текст комментария 3",
"likes": 4, "likes": 5,
"rating": 3, "rating": 3,
"date": "2025-02-01T10:00:00Z" "date": "2025-02-01T10:00:00Z"
}, },
{ {
"username": "Пользователь4", "username": "Пользователь4",
"text": "Текст комментария 4", "text": "Текст комментария 4",
"likes": 18, "likes": 15,
"rating": 2, "rating": 2,
"date": "2025-12-01T10:00:00Z" "date": "2025-12-01T10:00:00Z"
} }
@@ -3,183 +3,144 @@
"data": [ "data": [
{ {
"id": 1, "id": 1,
"title": "Elden Ring", "name": "The Witcher 3: Wild Hunt",
"image": "game17", "image": "game1",
"price": 3295, "text": "$10",
"old_price": 3599, "imgPath": "img_top_1",
"imgPath": "img_top_17", "description": "Эпическая RPG с открытым миром, в которой Геральт из Ривии охотится на монстров и раскрывает политические заговоры.",
"description": "Крупномасштабная RPG, действие которой происходит в обширном открытом мире c богатой мифологией и множеством опасных врагов.",
"category": "RPG" "category": "RPG"
}, },
{ {
"id": 2, "id": 2,
"title": "The Witcher 3: Wild Hunt", "name": "Red Dead Redemption 2",
"image": "game1",
"price": 990,
"old_price": 1200,
"imgPath": "img_top_1",
"description": "Эпическая RPG с открытым миром, в которой Геральт из Ривии охотится на монстров и раскрывает политические заговоры.",
"category": "RPG"
},
{
"id": 17,
"title": "Red Dead Redemption 2",
"image": "game2", "image": "game2",
"price": 980, "text": "$10",
"old_price": 3800,
"imgPath": "img_top_2", "imgPath": "img_top_2",
"description": "Приключенческая игра с открытым миром на Диком Западе, рассказывающая историю Артура Моргана.", "description": "Приключенческая игра с открытым миром на Диком Западе, рассказывающая историю Артура Моргана.",
"category": "Adventures" "category": "Adventures"
}, },
{ {
"id": 3, "id": 3,
"title": "Forza Horizon 5", "name": "Forza Horizon 5",
"image": "game3", "image": "game3",
"price": 1900, "text": "$10",
"imgPath": "img_top_3", "imgPath": "img_top_3",
"description": "Гоночная игра с огромным открытым миром, действие которой происходит в Мексике.", "description": "Гоночная игра с огромным открытым миром, действие которой происходит в Мексике.",
"category": "Race" "category": "Race"
}, },
{ {
"id": 4, "id": 4,
"title": "Atomic Heart", "name": "Atomic Heart",
"image": "game4", "image": "game4",
"price": 1200, "text": "$10",
"old_price": 2500,
"imgPath": "img_top_4", "imgPath": "img_top_4",
"description": "Экшен-шутер с элементами RPG, разворачивающийся в альтернативной Советской России.", "description": "Экшен-шутер с элементами RPG, разворачивающийся в альтернативной Советской России.",
"category": "Shooters" "category": "Shooters"
}, },
{ {
"id": 5, "id": 5,
"title": "Counter-Strike 2", "name": "Counter-Strike 2",
"image": "game5", "image": "game5",
"price": 479, "text": "$10",
"imgPath": "img_top_5", "imgPath": "img_top_5",
"description": "Популярный онлайн-шутер с соревновательным геймплеем и тактическими элементами.", "description": "Популярный онлайн-шутер с соревновательным геймплеем и тактическими элементами.",
"category": "Shooters" "category": "Shooters"
}, },
{ {
"id": 6, "id": 6,
"title": "Grand Theft Auto V", "name": "Grand Theft Auto V",
"image": "game6", "image": "game6",
"price": 700, "text": "$10",
"imgPath": "img_top_6", "imgPath": "img_top_6",
"description": "Игра с открытым миром, где можно погрузиться в криминальный мир Лос-Сантоса.", "description": "Игра с открытым миром, где можно погрузиться в криминальный мир Лос-Сантоса.",
"category": "Adventures" "category": "Adventures"
}, },
{ {
"id": 7, "id": 7,
"title": "Assassin’s Creed IV: Black Flag", "name": "Assassin’s Creed IV: Black Flag",
"image": "game7", "image": "game7",
"price": 1100, "text": "$10",
"imgPath": "img_top_7", "imgPath": "img_top_7",
"description": "Приключенческая игра о пиратах и морских сражениях в эпоху золотого века пиратства.", "description": "Приключенческая игра о пиратах и морских сражениях в эпоху золотого века пиратства.",
"category": "Adventures" "category": "Adventures"
}, },
{ {
"id": 8, "id": 8,
"title": "Spider-Man", "name": "Spider-Man",
"image": "game8", "image": "game8",
"price": 3800, "text": "$10",
"imgPath": "img_top_8", "imgPath": "img_top_8",
"description": "Игра о супергерое Человеке-пауке с захватывающими битвами и паркуром по Нью-Йорку.", "description": "Игра о супергерое Человеке-пауке с захватывающими битвами и паркуром по Нью-Йорку.",
"category": "Action" "category": "Action"
}, },
{ {
"id": 9, "id": 9,
"title": "Assassin’s Creed Mirage", "name": "Assassin’s Creed Mirage",
"image": "game9", "image": "game9",
"price": 1600, "text": "$10",
"imgPath": "img_top_9", "imgPath": "img_top_9",
"description": "Приключенческая игра с упором на скрытность, вдохновленная классическими частями серии.", "description": "Приключенческая игра с упором на скрытность, вдохновленная классическими частями серии.",
"category": "Action" "category": "Action"
}, },
{ {
"id": 10, "id": 10,
"title": "Assassin’s Creed Valhalla", "name": "Assassin’s Creed Valhalla",
"image": "game10", "image": "game10",
"price": 800, "text": "$10",
"old_price": 2200,
"imgPath": "img_top_10", "imgPath": "img_top_10",
"description": "RPG с открытым миром о викингах, включающая битвы, исследования и строительство поселений.", "description": "RPG с открытым миром о викингах, включающая битвы, исследования и строительство поселений.",
"category": "RPG" "category": "RPG"
}, },
{ {
"id": 11, "id": 11,
"title": "ARK: Survival Evolved", "name": "ARK: Survival Evolved",
"image": "game11", "image": "game11",
"price": 790, "text": "$10",
"imgPath": "img_top_11", "imgPath": "img_top_11",
"description": "Выживание в открытом мире с динозаврами, строительством и многопользовательскими элементами.", "description": "Выживание в открытом мире с динозаврами, строительством и многопользовательскими элементами.",
"category": "Simulators" "category": "Simulators"
}, },
{ {
"id": 12, "id": 12,
"title": "FIFA 23", "name": "FIFA 23",
"image": "game12", "image": "game12",
"price": 3900, "text": "$10",
"imgPath": "img_top_12", "imgPath": "img_top_12",
"description": "Популярный футбольный симулятор с улучшенной графикой и реалистичным геймплеем.", "description": "Популярный футбольный симулятор с улучшенной графикой и реалистичным геймплеем.",
"category": "Sports" "category": "Sports"
}, },
{ {
"id": 13, "id": 13,
"title": "Dirt 5", "name": "Dirt 5",
"image": "game13", "image": "game13",
"price": 2300, "text": "$10",
"imgPath": "img_top_13", "imgPath": "img_top_13",
"description": "Аркадная гоночная игра с фокусом на ралли и внедорожных соревнованиях.", "description": "Аркадная гоночная игра с фокусом на ралли и внедорожных соревнованиях.",
"category": "Race" "category": "Race"
}, },
{ {
"id": 14, "id": 14,
"title": "Cyberpunk 2077", "name": "Cyberpunk 2077",
"image": "game14", "image": "game14",
"price": 3400, "text": "$10",
"imgPath": "img_top_14", "imgPath": "img_top_14",
"description": "RPG в киберпанк-сеттинге с нелинейным сюжетом и детализированным открытым миром.", "description": "RPG в киберпанк-сеттинге с нелинейным сюжетом и детализированным открытым миром.",
"category": "RPG" "category": "RPG"
}, },
{ {
"id": 15, "id": 15,
"title": "Age of Empires IV", "name": "Age of Empires IV",
"image": "game15", "image": "game15",
"price": 3200, "text": "$10",
"imgPath": "img_top_15", "imgPath": "img_top_15",
"description": "Классическая стратегия в реальном времени с историческими кампаниями.", "description": "Классическая стратегия в реальном времени с историческими кампаниями.",
"category": "Strategies" "category": "Strategies"
}, },
{ {
"id": 16, "id": 16,
"title": "Civilization VI", "name": "Civilization VI",
"image": "game16", "image": "game16",
"price": 4200, "text": "$10",
"imgPath": "img_top_16", "imgPath": "img_top_16",
"description": "Глобальная пошаговая стратегия, в которой игроки строят и развивают цивилизации.", "description": "Глобальная пошаговая стратегия, в которой игроки строят и развивают цивилизации.",
"category": "Strategies" "category": "Strategies"
@@ -1,16 +0,0 @@
{
"success": true,
"data": {
"ids": [
3,
13,
1,
10,
4,
9,
15,
6,
7
]
}
}
@@ -3,51 +3,43 @@
"data": { "data": {
"topSail": [ "topSail": [
{ {
"id": 1,
"image": "game1", "image": "game1",
"price": 1500, "text": "$10",
"imgPath": "img_top_1" "imgPath": "img_top_1"
}, },
{ {
"id": 2,
"image": "game2", "image": "game2",
"price": 980, "text": "$10",
"imgPath": "img_top_2" "imgPath": "img_top_2"
}, },
{ {
"id": 3,
"image": "game3", "image": "game3",
"price": 1900, "text": "$10",
"imgPath": "img_top_3" "imgPath": "img_top_3"
}, },
{ {
"id": 4,
"image": "game4", "image": "game4",
"price": 1200, "text": "$10",
"imgPath": "img_top_4" "imgPath": "img_top_4"
}, },
{ {
"id": 5,
"image": "game5", "image": "game5",
"price": 479, "text": "$10",
"imgPath": "img_top_5" "imgPath": "img_top_5"
}, },
{ {
"id": 6,
"image": "game6", "image": "game6",
"price": 700, "text": "$10",
"imgPath": "img_top_6" "imgPath": "img_top_6"
}, },
{ {
"id": 7,
"image": "game7", "image": "game7",
"price": 1100, "text": "$10",
"imgPath": "img_top_7" "imgPath": "img_top_7"
}, },
{ {
"id": 8,
"image": "game8", "image": "game8",
"price": 3800, "text": "$10",
"imgPath": "img_top_8" "imgPath": "img_top_8"
} }
], ],
@@ -105,26 +97,22 @@
{ {
"image": "news1", "image": "news1",
"text": "Разработчики Delta Force: Hawk Ops представили крупномасштабный режим Havoc Warfare", "text": "Разработчики Delta Force: Hawk Ops представили крупномасштабный режим Havoc Warfare",
"imgPath": "img_news_1", "imgPath": "img_news_1"
"link": "https://gamemag.ru/news/185583/delta-force-hawk-ops-gameplay-showcase-havoc-warfare"
}, },
{ {
"image": "news2", "image": "news2",
"text": "Первый трейлер Assassin’s Creed Shadows — с темнокожим самураем в феодальной Японии", "text": "Первый трейлер Assassin’s Creed Shadows — с темнокожим самураем в феодальной Японии",
"imgPath": "img_news_2", "imgPath": "img_news_2"
"link": "https://stopgame.ru/newsdata/62686/pervyy_trailer_assassin_s_creed_shadows_s_temnokozhim_samuraem_v_feodalnoy_yaponii"
}, },
{ {
"image": "news3", "image": "news3",
"text": "Призрак Цусимы» вышел на ПК — и уже ставит рекорды для Sony", "text": "Призрак Цусимы» вышел на ПК — и уже ставит рекорды для Sony",
"imgPath": "img_news_3", "imgPath": "img_news_3"
"link": "https://stopgame.ru/newsdata/62706/prizrak_cusimy_vyshel_na_pk_i_uzhe_stavit_rekordy_dlya_sony"
}, },
{ {
"image": "news4", "image": "news4",
"text": "Авторы Skull and Bones расширяют планы на второй сезон", "text": "Авторы Skull and Bones расширяют планы на второй сезо",
"imgPath": "img_news_4", "imgPath": "img_news_4"
"link": "https://stopgame.ru/newsdata/62711/avtory_skull_and_bones_rasshiryayut_plany_na_vtoroy_sezon"
} }
] ]
} }
-3
View File
@@ -1,3 +0,0 @@
exports.KAZAN_EXPLORE_RESULTS_MODEL_NAME = 'KAZAN_EXPLORE_RESULTS'
exports.TOKEN_KEY = "KAZAN_EXPLORE_TOP_SECRET_TOKEN_KEY"
+9 -48
View File
@@ -1,54 +1,15 @@
const router = require('express').Router(); const router = require('express').Router();
const { ResultsModel } = require('./model/results')
router.get('/getQuizResults/:userId', async (request, response) => {
const { userId } = request.params;
try {
const results = await ResultsModel.findOne({ userId : userId }).exec();
if (!results) {
return response.status(404).send({ message: 'Quiz results not found' });
}
response.send(results.items);
} catch (error) {
response.status(500).send({ message: 'An error occurred while fetching quiz results' });
}
});
router.post('/addQuizResult', async (request, response) => {
const { userId, quizId, result } = request.body;
if (!userId || !quizId || !result) {
return response.status(400).send({ message: 'Invalid input data' });
}
try {
let userResults = await ResultsModel.findOne({ userId : userId }).exec();
if (!userResults) {
userResults = new ResultsModel({ userId, items: [] });
}
userResults.items.push({ quizId, result });
await userResults.save();
response.status(200).send({ message: 'Quiz result added successfully', data: userResults });
} catch (error) {
response.status(500).send({ message: 'An error occurred while adding quiz result' });
}
});
// First page // First page
router.get('/getInfoAboutKazan', (request, response) => { router.get('/getInfoAboutKazan', (request, response) => {
const lang = request.query.lang || 'ru'; const lang = request.query.lang || 'ru'; // Получаем язык из параметров запроса
try { try {
const data = require('./json/first/info-about-kazan/success.json'); const data = require('./json/first/info-about-kazan/success.json'); // Загружаем весь JSON
const translatedData = data[lang] || data['ru']; const translatedData = data[lang] || data['ru']; // Выбираем перевод по языку или дефолтный
response.send(translatedData); response.send(translatedData); // Отправляем перевод клиенту
} catch (error) { } catch (error) {
response.status(500).send({ message: 'Internal server error' }); response.status(500).send({ message: 'Internal server error' }); // Ошибка в случае проблем с JSON
} }
}); });
@@ -64,13 +25,13 @@ router.get('/getNews', (request, response) => {
// Sport page // Sport page
router.get('/getFirstText', (request, response) => { router.get('/getFirstText', (request, response) => {
const lang = request.query.lang || 'ru'; const lang = request.query.lang || 'ru'; // Получаем язык из параметров
try { try {
const data = require('./json/sport/first-text/success.json'); const data = require('./json/sport/first-text/success.json'); // Загружаем JSON
const translatedData = data[lang] || data['ru']; const translatedData = data[lang] || data['ru']; // Берём перевод или дефолтный
response.send(translatedData); response.send(translatedData);
} catch (error) { } catch (error) {
response.status(404).send({ message: 'Language not found' }); response.status(404).send({ message: 'Language not found' }); // Обработка ошибки
} }
}); });
@@ -1,27 +0,0 @@
const { Schema, model } = require('mongoose')
const { KAZAN_EXPLORE_RESULTS_MODEL_NAME } = require('../const')
const schema = new Schema({
userId: { type: String },
items: [
{
quizId: { type: String },
result: { type: Number }
}
]
})
schema.set('toJSON', {
virtuals: true,
versionKey: false,
transform: function (doc, ret) {
delete ret._id
}
})
schema.virtual('id').get(function () {
return this._id.toHexString()
})
exports.ResultsModel = model(KAZAN_EXPLORE_RESULTS_MODEL_NAME, schema)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 307 files, more files were not shown because too many files have changed in this diff. Show more