Compare commits
3 Commits
kfu-m-24-1
...
771f75ef08
| Author | SHA1 | Date | |
|---|---|---|---|
| 771f75ef08 | |||
|
|
edf9b2c82b | ||
| a88d3657bf |
@@ -12,6 +12,10 @@ router.get("/categories", (request, response) => {
|
|||||||
response.send(require("./json/home-page-data/all-games.json"));
|
response.send(require("./json/home-page-data/all-games.json"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.get("/favourites", (request, response) => {
|
||||||
|
response.send(require("./json/home-page-data/all-games.json"));
|
||||||
|
});
|
||||||
|
|
||||||
router.get("/shopping-cart", (request, response) => {
|
router.get("/shopping-cart", (request, response) => {
|
||||||
response.send(require("./json/shopping-cart/success.json"));
|
response.send(require("./json/shopping-cart/success.json"));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,41 +3,43 @@
|
|||||||
"data": [
|
"data": [
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
|
"title": "Elden Ring",
|
||||||
|
"image": "game17",
|
||||||
|
"price": 3295,
|
||||||
|
"old_price": 3599,
|
||||||
|
"imgPath": "img_top_17",
|
||||||
|
"description": "Крупномасштабная RPG, действие которой происходит в обширном открытом мире c богатой мифологией и множеством опасных врагов.",
|
||||||
|
"category": "RPG"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
"title": "The Witcher 3: Wild Hunt",
|
"title": "The Witcher 3: Wild Hunt",
|
||||||
"image": "game1",
|
"image": "game1",
|
||||||
"price": 990,
|
"price": 990,
|
||||||
"old_price": 1200,
|
"old_price": 1200,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_1",
|
"imgPath": "img_top_1",
|
||||||
"description": "Эпическая RPG с открытым миром, в которой Геральт из Ривии охотится на монстров и раскрывает политические заговоры.",
|
"description": "Эпическая RPG с открытым миром, в которой Геральт из Ривии охотится на монстров и раскрывает политические заговоры.",
|
||||||
"category": "RPG"
|
"category": "RPG"
|
||||||
,"fav1": "star1",
|
|
||||||
"fav2": "star2"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 2,
|
"id": 17,
|
||||||
"title": "Red Dead Redemption 2",
|
"title": "Red Dead Redemption 2",
|
||||||
"image": "game2",
|
"image": "game2",
|
||||||
"price": 980,
|
"price": 980,
|
||||||
"old_price": 3800,
|
"old_price": 3800,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_2",
|
"imgPath": "img_top_2",
|
||||||
"description": "Приключенческая игра с открытым миром на Диком Западе, рассказывающая историю Артура Моргана.",
|
"description": "Приключенческая игра с открытым миром на Диком Западе, рассказывающая историю Артура Моргана.",
|
||||||
"category": "Adventures"
|
"category": "Adventures"
|
||||||
,"fav1": "star1",
|
|
||||||
"fav2": "star2"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 3,
|
"id": 3,
|
||||||
"title": "Forza Horizon 5",
|
"title": "Forza Horizon 5",
|
||||||
"image": "game3",
|
"image": "game3",
|
||||||
"price": 1900,
|
"price": 1900,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_3",
|
"imgPath": "img_top_3",
|
||||||
"description": "Гоночная игра с огромным открытым миром, действие которой происходит в Мексике.",
|
"description": "Гоночная игра с огромным открытым миром, действие которой происходит в Мексике.",
|
||||||
"category": "Race"
|
"category": "Race"
|
||||||
,"fav1": "star1",
|
|
||||||
"fav2": "star2"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 4,
|
"id": 4,
|
||||||
@@ -45,72 +47,66 @@
|
|||||||
"image": "game4",
|
"image": "game4",
|
||||||
"price": 1200,
|
"price": 1200,
|
||||||
"old_price": 2500,
|
"old_price": 2500,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_4",
|
"imgPath": "img_top_4",
|
||||||
"description": "Экшен-шутер с элементами RPG, разворачивающийся в альтернативной Советской России.",
|
"description": "Экшен-шутер с элементами RPG, разворачивающийся в альтернативной Советской России.",
|
||||||
"category": "Shooters"
|
"category": "Shooters"
|
||||||
,"fav1": "star1",
|
|
||||||
"fav2": "star2"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 5,
|
"id": 5,
|
||||||
"title": "Counter-Strike 2",
|
"title": "Counter-Strike 2",
|
||||||
"image": "game5",
|
"image": "game5",
|
||||||
"price": 479,
|
"price": 479,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_5",
|
"imgPath": "img_top_5",
|
||||||
"description": "Популярный онлайн-шутер с соревновательным геймплеем и тактическими элементами.",
|
"description": "Популярный онлайн-шутер с соревновательным геймплеем и тактическими элементами.",
|
||||||
"category": "Shooters"
|
"category": "Shooters"
|
||||||
,"fav1": "star1",
|
|
||||||
"fav2": "star2"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 6,
|
"id": 6,
|
||||||
"title": "Grand Theft Auto V",
|
"title": "Grand Theft Auto V",
|
||||||
"image": "game6",
|
"image": "game6",
|
||||||
"price": 700,
|
"price": 700,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_6",
|
"imgPath": "img_top_6",
|
||||||
"description": "Игра с открытым миром, где можно погрузиться в криминальный мир Лос-Сантоса.",
|
"description": "Игра с открытым миром, где можно погрузиться в криминальный мир Лос-Сантоса.",
|
||||||
"category": "Adventures"
|
"category": "Adventures"
|
||||||
,"fav1": "star1",
|
|
||||||
"fav2": "star2"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 7,
|
"id": 7,
|
||||||
"title": "Assassin’s Creed IV: Black Flag",
|
"title": "Assassin’s Creed IV: Black Flag",
|
||||||
"image": "game7",
|
"image": "game7",
|
||||||
"price": 1100,
|
"price": 1100,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_7",
|
"imgPath": "img_top_7",
|
||||||
"description": "Приключенческая игра о пиратах и морских сражениях в эпоху золотого века пиратства.",
|
"description": "Приключенческая игра о пиратах и морских сражениях в эпоху золотого века пиратства.",
|
||||||
"category": "Adventures"
|
"category": "Adventures"
|
||||||
,"fav1": "star1",
|
|
||||||
"fav2": "star2"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 8,
|
"id": 8,
|
||||||
"title": "Spider-Man",
|
"title": "Spider-Man",
|
||||||
"image": "game8",
|
"image": "game8",
|
||||||
"price": 3800,
|
"price": 3800,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_8",
|
"imgPath": "img_top_8",
|
||||||
"description": "Игра о супергерое Человеке-пауке с захватывающими битвами и паркуром по Нью-Йорку.",
|
"description": "Игра о супергерое Человеке-пауке с захватывающими битвами и паркуром по Нью-Йорку.",
|
||||||
"category": "Action"
|
"category": "Action"
|
||||||
,"fav1": "star1",
|
|
||||||
"fav2": "star2"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 9,
|
"id": 9,
|
||||||
"title": "Assassin’s Creed Mirage",
|
"title": "Assassin’s Creed Mirage",
|
||||||
"image": "game9",
|
"image": "game9",
|
||||||
"price": 1600,
|
"price": 1600,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_9",
|
"imgPath": "img_top_9",
|
||||||
"description": "Приключенческая игра с упором на скрытность, вдохновленная классическими частями серии.",
|
"description": "Приключенческая игра с упором на скрытность, вдохновленная классическими частями серии.",
|
||||||
"category": "Action"
|
"category": "Action"
|
||||||
,"fav1": "star1",
|
|
||||||
"fav2": "star2"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 10,
|
"id": 10,
|
||||||
@@ -118,79 +114,72 @@
|
|||||||
"image": "game10",
|
"image": "game10",
|
||||||
"price": 800,
|
"price": 800,
|
||||||
"old_price": 2200,
|
"old_price": 2200,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_10",
|
"imgPath": "img_top_10",
|
||||||
"description": "RPG с открытым миром о викингах, включающая битвы, исследования и строительство поселений.",
|
"description": "RPG с открытым миром о викингах, включающая битвы, исследования и строительство поселений.",
|
||||||
"category": "RPG"
|
"category": "RPG"
|
||||||
,"fav1": "star1",
|
|
||||||
"fav2": "star2"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 11,
|
"id": 11,
|
||||||
"title": "ARK: Survival Evolved",
|
"title": "ARK: Survival Evolved",
|
||||||
"image": "game11",
|
"image": "game11",
|
||||||
"price": 790,
|
"price": 790,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_11",
|
"imgPath": "img_top_11",
|
||||||
"description": "Выживание в открытом мире с динозаврами, строительством и многопользовательскими элементами.",
|
"description": "Выживание в открытом мире с динозаврами, строительством и многопользовательскими элементами.",
|
||||||
"category": "Simulators"
|
"category": "Simulators"
|
||||||
,"fav1": "star1",
|
|
||||||
"fav2": "star2"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 12,
|
"id": 12,
|
||||||
"title": "FIFA 23",
|
"title": "FIFA 23",
|
||||||
"image": "game12",
|
"image": "game12",
|
||||||
"price": 3900,
|
"price": 3900,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_12",
|
"imgPath": "img_top_12",
|
||||||
"description": "Популярный футбольный симулятор с улучшенной графикой и реалистичным геймплеем.",
|
"description": "Популярный футбольный симулятор с улучшенной графикой и реалистичным геймплеем.",
|
||||||
"category": "Sports"
|
"category": "Sports"
|
||||||
,"fav1": "star1",
|
|
||||||
"fav2": "star2"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 13,
|
"id": 13,
|
||||||
"title": "Dirt 5",
|
"title": "Dirt 5",
|
||||||
"image": "game13",
|
"image": "game13",
|
||||||
"price": 2300,
|
"price": 2300,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_13",
|
"imgPath": "img_top_13",
|
||||||
"description": "Аркадная гоночная игра с фокусом на ралли и внедорожных соревнованиях.",
|
"description": "Аркадная гоночная игра с фокусом на ралли и внедорожных соревнованиях.",
|
||||||
"category": "Race"
|
"category": "Race"
|
||||||
,"fav1": "star1",
|
|
||||||
"fav2": "star2"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 14,
|
"id": 14,
|
||||||
"title": "Cyberpunk 2077",
|
"title": "Cyberpunk 2077",
|
||||||
"image": "game14",
|
"image": "game14",
|
||||||
"price": 3400,
|
"price": 3400,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_14",
|
"imgPath": "img_top_14",
|
||||||
"description": "RPG в киберпанк-сеттинге с нелинейным сюжетом и детализированным открытым миром.",
|
"description": "RPG в киберпанк-сеттинге с нелинейным сюжетом и детализированным открытым миром.",
|
||||||
"category": "RPG"
|
"category": "RPG"
|
||||||
,"fav1": "star1",
|
|
||||||
"fav2": "star2"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 15,
|
"id": 15,
|
||||||
"title": "Age of Empires IV",
|
"title": "Age of Empires IV",
|
||||||
"image": "game15",
|
"image": "game15",
|
||||||
"price": 3200,
|
"price": 3200,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_15",
|
"imgPath": "img_top_15",
|
||||||
"description": "Классическая стратегия в реальном времени с историческими кампаниями.",
|
"description": "Классическая стратегия в реальном времени с историческими кампаниями.",
|
||||||
"category": "Strategies"
|
"category": "Strategies"
|
||||||
,"fav1": "star1",
|
|
||||||
"fav2": "star2"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 16,
|
"id": 16,
|
||||||
"title": "Civilization VI",
|
"title": "Civilization VI",
|
||||||
"image": "game16",
|
"image": "game16",
|
||||||
"price": 4200,
|
"price": 4200,
|
||||||
"os": "windows",
|
|
||||||
"imgPath": "img_top_16",
|
"imgPath": "img_top_16",
|
||||||
"description": "Глобальная пошаговая стратегия, в которой игроки строят и развивают цивилизации.",
|
"description": "Глобальная пошаговая стратегия, в которой игроки строят и развивают цивилизации.",
|
||||||
"category": "Strategies"
|
"category": "Strategies"
|
||||||
|
|||||||
@@ -1,24 +1,25 @@
|
|||||||
[
|
[
|
||||||
|
{ "id": 1, "description": "1000 часто используемых", "imageFilename": "kart1.jpg", "words": [0, 1] },
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 2,
|
||||||
"description": "10 слов в Data Science",
|
"description": "10 слов в Data Science",
|
||||||
"imageFilename": "kart1.jpg",
|
"imageFilename": "kart1.jpg",
|
||||||
"words": [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
"words": [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 2,
|
"id": 3,
|
||||||
"description": "Job Interview",
|
"description": "Job Interview",
|
||||||
"imageFilename": "kart1.jpg",
|
"imageFilename": "kart1.jpg",
|
||||||
"words": [13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
|
"words": [13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 3,
|
"id": 4,
|
||||||
"description": "ReactJS",
|
"description": "ReactJS",
|
||||||
"imageFilename": "kart1.jpg",
|
"imageFilename": "kart1.jpg",
|
||||||
"words": [23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
"words": [23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 4,
|
"id": 5,
|
||||||
"description": "NodeJS",
|
"description": "NodeJS",
|
||||||
"imageFilename": "kart1.jpg",
|
"imageFilename": "kart1.jpg",
|
||||||
"words": [33, 34, 35, 36, 37, 38, 39, 40, 41, 42]
|
"words": [33, 34, 35, 36, 37, 38, 39, 40, 41, 42]
|
||||||
|
|||||||
@@ -5,16 +5,15 @@ const router = require('express').Router();
|
|||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
||||||
const data = require('./units.json');
|
const data = require('./units.json');
|
||||||
|
const users = require('../users/users.json');
|
||||||
router.get('/', (req, res) => {
|
router.get('/', (req, res) => {
|
||||||
// for every data set author from users and save it to authoredData variable
|
// for every data set author from users and save it to authoredData variable
|
||||||
const users = require('../users/users.json');
|
|
||||||
const authoredData = data.map((unit) => {
|
const authoredData = data.map((unit) => {
|
||||||
const user = users.find((user) => user.public_id == unit.author);
|
const user = users.find((user) => user.public_id == unit.author);
|
||||||
let authoredUnit = undefined;
|
|
||||||
if (user) {
|
if (user) {
|
||||||
authoredUnit = { ...unit, author: user };
|
unit.author = user;
|
||||||
}
|
}
|
||||||
return authoredUnit;
|
return unit;
|
||||||
});
|
});
|
||||||
|
|
||||||
res.send(authoredData);
|
res.send(authoredData);
|
||||||
@@ -40,8 +39,9 @@ router.post('/:id', (req, res) => {
|
|||||||
|
|
||||||
data.splice(index, 1);
|
data.splice(index, 1);
|
||||||
|
|
||||||
data.push({...updatedUnit, author: updatedUnit.author.public_id});
|
data.push(updatedUnit);
|
||||||
|
|
||||||
|
fs.writeFileSync(path.join(__dirname, 'units.json'), JSON.stringify(data));
|
||||||
res.status(200).send(data);
|
res.status(200).send(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -61,8 +61,12 @@ router.put('/', (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const newId = data.length + 1;
|
const newId = data.length + 1;
|
||||||
data.push({ ...newUnit, id: newId });
|
// const filename = newUnit.name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
||||||
|
// fs.writeFileSync(path.join(__dirname, 'data', `${filename}.md`), newUnit.content);
|
||||||
|
|
||||||
|
data.push({ ...unit, id: newId });
|
||||||
|
|
||||||
|
fs.writeFileSync(path.join(__dirname, 'units.json'), JSON.stringify(data));
|
||||||
res.status(200).send(data);
|
res.status(200).send(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -75,11 +79,11 @@ router.delete('/:id', (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
data.splice(index, 1);
|
data.splice(index, 1);
|
||||||
|
fs.writeFileSync(path.join(__dirname, 'units.json'), JSON.stringify(data));
|
||||||
res.send({ message: `Unit with ID ${id} deleted` });
|
res.send({ message: `Unit with ID ${id} deleted` });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/:id', (req, res) => {
|
router.get('/:id', (req, res) => {
|
||||||
const users = require('../users/users.json');
|
|
||||||
const id = parseInt(req.params.id);
|
const id = parseInt(req.params.id);
|
||||||
const unit = data.find((unit) => unit.id === id);
|
const unit = data.find((unit) => unit.id === id);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const fs = require('fs');
|
|||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
||||||
let data = require('./users.json');
|
const data = require('./users.json');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
router.get('/', (req, res) => {
|
router.get('/', (req, res) => {
|
||||||
res.send(data);
|
res.send(data);
|
||||||
@@ -11,15 +11,20 @@ router.get('/', (req, res) => {
|
|||||||
|
|
||||||
router.post('/', (req, res) => {
|
router.post('/', (req, res) => {
|
||||||
const newUser = req.body;
|
const newUser = req.body;
|
||||||
|
const updatedData = [...data, newUser];
|
||||||
|
|
||||||
|
console.log(updatedData);
|
||||||
|
fs.writeFileSync(path.join(__dirname, 'users.json'), JSON.stringify(updatedData));
|
||||||
|
|
||||||
data.push(newUser);
|
res.send(updatedData);
|
||||||
fs.writeFileSync(path.join(__dirname, 'users.json'), JSON.stringify(data));
|
|
||||||
res.send(data);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/login', (req, res) => {
|
router.post('/login', (req, res) => {
|
||||||
const { email, password } = req.body;
|
const { email, password } = req.body;
|
||||||
|
console.log(email);
|
||||||
|
console.log(req.body);
|
||||||
const user = data.find((user) => user.email === email && user.password === password);
|
const user = data.find((user) => user.email === email && user.password === password);
|
||||||
|
console.log(user);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
res.status(404).send('Пользователь не найден');
|
res.status(404).send('Пользователь не найден');
|
||||||
@@ -29,11 +34,13 @@ router.post('/login', (req, res) => {
|
|||||||
|
|
||||||
router.get('/account', (req, res) => {
|
router.get('/account', (req, res) => {
|
||||||
const { public_id } = req.query;
|
const { public_id } = req.query;
|
||||||
|
console.log(public_id);
|
||||||
const user = data.find((user) => user.public_id == public_id);
|
const user = data.find((user) => user.public_id == public_id);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
res.status(404).send('Пользователь не найден');
|
res.status(404).send('Пользователь не найден');
|
||||||
}
|
}
|
||||||
|
console.log(user);
|
||||||
res.send({ ...user, id: -1 });
|
res.send({ ...user, id: -1 });
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -47,6 +54,7 @@ router.post('/account/save', (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
data[index] = { ...data[index], ...updatedUser, id: data[index].id, password: data[index].password };
|
data[index] = { ...data[index], ...updatedUser, id: data[index].id, password: data[index].password };
|
||||||
|
|
||||||
fs.writeFileSync(path.join(__dirname, 'users.json'), JSON.stringify(data));
|
fs.writeFileSync(path.join(__dirname, 'users.json'), JSON.stringify(data));
|
||||||
|
|
||||||
res.status(200);
|
res.status(200);
|
||||||
|
|||||||
Reference in New Issue
Block a user