edit json files

This commit is contained in:
nothingnowhere1 2024-05-25 12:44:44 +03:00
parent 0a6d50cb60
commit eb87f400ee
3 changed files with 199 additions and 33 deletions

View File

@ -1,11 +1,30 @@
const router = require('express').Router(); const router = require('express').Router();
router.get('/catalog-data', (request, response) => { router.get('/catalog-data', (request, response) => {
response.send(require('./json/catalog-data/success.json')) response.send(require('./stubs/json/catalog-data/success.json'))
}) })
router.get('/catalog-data', (request, response) => { router.get('/item-data', (request, response) => {
response.send(require('./json/item-data/newsuccess.json')) response.send(require('./stubs/json/catalog-data/newsuccess.json'))
}) })
router.post('/search', (request, response) => {
const searchTerm = request.body.search.toLowerCase();
try {
const itemsData = require('./stubs/json/catalog-data/newsuccess.json');
const itemData = itemsData.data.find(item => item.name.toLowerCase().includes(searchTerm));
if (itemData) {
return response.json({ data: itemData });
} else {
console.log('Item not found');
return response.status(404).send('Item not found');
}
} catch (error) {
console.error('Error reading file:', error);
return response.status(500).send('Internal server error');
}
});
module.exports = router; module.exports = router;

View File

@ -1,33 +1,52 @@
{ {
"data": [ "data":[
[{"photo": "shirt2_1x", [{
"alt" :"ХУДИ УТЕПЛЕННОЕ", "id": 1,
"name": "ХУДИ УТЕПЛЕННОЕ", "photo": "shirt7_1x",
"alt" :"ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'",
"name": "ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'",
"price": "1500 руб.", "price": "1500 руб.",
"setphoto": ["shirt2_1x","shirt2_2x", "shirt2_4x"]}, "setphoto": ["shirt7_1x","shirt7_2x","shirt7_4x"]
{"photo": "shirt3_1x", },
"alt" :"РУБАШКА МУЖСКАЯ", {
"name": "РУБАШКА МУЖСКАЯ", "id":2,
"photo": "shirt8_1x",
"alt" :"ЗИП МУЖСКОЙ",
"name": "ЗИП МУЖСКОЙ",
"price": "1500 руб.", "price": "1500 руб.",
"setphoto": ["shirt3_1x","shirt3_2x", "shirt3_4x"]}, "setphoto": ["shirt8_1x","shirt8_2x","shirt8_4x"]
{"photo": "shirt4_1x", },
"alt" :"ТРЕНЧ ЖЕНСКИЙ", {
"name": "ТРЕНЧ ЖЕНСКИЙ", "id": 3,
"photo": "shirt1_1x",
"alt" :"Фотография футболки белого цвета с цитатой из К/ф Кавказская пленница",
"name": "ФУТБОЛКА С ПРИНТОМ МОСФИЛЬМ",
"price": "1500 руб.", "price": "1500 руб.",
"setphoto": ["shirt4_1x","shirt4_2x", "shirt4_4x"]}], "setphoto": ["shirt1_1x","shirt1_2x","shirt1_4x"]
[{"photo": "shirt6_1x", }],
"alt" :"ФУТБОЛКА С ОРНАМЕНТОМ ПЕЙСЛИ", [{
"name": "ФУТБОЛКА С ОРНАМЕНТОМ ПЕЙСЛИ", "id": 4,
"photo": "shirt9_1x",
"alt" :"ЛАВАНДОВОЕ ХУДИ",
"name": "ЛАВАНДОВОЕ ХУДИ",
"price": "1500 руб.", "price": "1500 руб.",
"setphoto": ["shirt6_1x","shirt6_2x", "shirt6_4x"]}, "setphoto": ["shirt9_1x","shirt9_2x","shirt9_4x"]
{"photo": "shirt5_1x", },
"alt" :"ЗИП С ПРИНТОМ", {
"name": "ЗИП С ПРИНТОМ", "id": 5,
"photo": "shirt10_1x",
"alt" :"ФУТБОЛКА АНИМЕ",
"name": "ФУТБОЛКА АНИМЕ",
"price": "1500 руб.", "price": "1500 руб.",
"setphoto": ["shirt5_1x","shirt5_2x", "shirt5_4x"]}, "setphoto": ["shirt10_1x","shirt10_2x","shirt10_4x"]
{"photo": "shirt1_1x", },
"alt" :"ФУТБОЛКА С ОРНАМЕНТОМ МОСФИЛЬМ", {
"name": "ФУТБОЛКА С ОРНАМЕНТОМ МОСФИЛЬМ", "id": 6,
"photo":"shirt11_1x",
"alt" :"ФУТБОЛКА ОВЕРСАЙЗ С ПРИНТОМ ЭРАРТА",
"name": "ФУТБОЛКА ОВЕРСАЙЗ С ПРИНТОМ ЭРАРТА",
"price": "1500 руб.", "price": "1500 руб.",
"setphoto": ["shirt1_1x","shirt1_2x", "shirt1_4x"]}]] "setphoto": ["shirt11_1x","shirt11_2x", "shirt11_4x"]
}]
]
} }

View File

@ -1,11 +1,15 @@
{ {
"data":[ "data":[
{ {
"photo": ["shirt7_1x", "shirt7.1_1x"], "id": 1,
"photo": ["shirt7_1x", "shirt7_1_1x"],
"alt" :"ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'", "alt" :"ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'",
"name": "ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'", "name": "ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'",
"price": "1500 руб.", "price": "1500 руб.",
"setphoto": ["shirt7_1x","shirt7.1_1x","shirt7_2x","shirt7.2_2x", "shirt7_4x", "shirt7.2_4x"], "color" : "Серый",
"colorid" : 7,
"colorcss": ["#606060","#FFFFFF"],
"setphoto": ["shirt7_1x","shirt7_1_1x","shirt7_2x","shirt7_1_2x", "shirt7_4x", "shirt7_1_4x"],
"size": ["XS/S","M/L","XL/XLL"], "size": ["XS/S","M/L","XL/XLL"],
"body": ["79653", "body": ["79653",
"Весна-Лето 2023", "Весна-Лето 2023",
@ -24,11 +28,12 @@
"Женский"] "Женский"]
}, },
{ {
"photo": ["shirt8_1x", "shirt8.2_1x"], "id":2,
"photo": ["shirt8_1x", "shirt8_1_1x"],
"alt" :"ЗИП МУЖСКОЙ", "alt" :"ЗИП МУЖСКОЙ",
"name": "ЗИП МУЖСКОЙ", "name": "ЗИП МУЖСКОЙ",
"price": "1500 руб.", "price": "1500 руб.",
"setphoto": ["shirt8_1x","shirt8.2_1x","shirt8_2x","shirt8.1_2x", "shirt8_4x", "shirt8.1_4x"], "setphoto": ["shirt8_1x","shirt8_1_1x","shirt8_2x","shirt8_1_2x", "shirt8_4x", "shirt8_1_4x"],
"size": ["XS/S","M/L","XL/XLL"], "size": ["XS/S","M/L","XL/XLL"],
"body": ["7934", "body": ["7934",
"Весна-Осень 2023", "Весна-Осень 2023",
@ -45,6 +50,129 @@
"с карманами", "с карманами",
"160", "160",
"Мужской"] "Мужской"]
},
{
"id": 3,
"photo": ["shirt1_1x", "shirt1_1_1x"],
"alt" :"Фотография футболки белого цвета с цитатой из К/ф Кавказская пленница",
"name": "Футболка с принтом Мосфильм",
"price": "1500 руб.",
"setphoto": ["shirt1_1x","shirt1_1_1x","shirt1_2x","shirt1_1_2x", "shirt1_4x", "shirt1_1_4x"],
"size": ["XS/S","M/L","XL/XLL"],
"body": ["79776",
"Весна-Лето 2021",
"Третьяковская галерея",
"без застежки",
"темно-серый",
"100% Хлопок",
"свободный",
"надписи",
"удлиненная",
"101-78-96",
"189",
"L (50)",
"без карманов",
"160",
"Женский"]
},
{
"id": 4,
"photo": ["shirt9_1x", "shirt9.1_1x"],
"alt" :"ЛАВАНДОВОЕ ХУДИ",
"name": "ЛАВАНДОВОЕ ХУДИ",
"price": "1500 руб.",
"setphoto": ["shirt9_1x","shirt9.1_1x","shirt9_2x","shirt9.1_2x", "shirt9_4x", "shirt9.1_4x"],
"size": ["XS/S","M/L","XL/XLL"],
"body": ["79276",
"Весна-Лето 2021",
"Третьяковская галерея",
"без застежки",
"лавандовы",
"100% Хлопок",
"свободный",
"надписи",
"удлиненная",
"101-78-96",
"184",
"L (50)",
"с карманами",
"160",
"Женский"]
},
{
"id": 5,
"photo": ["shirt10_1x", "shirt10.1_1x"],
"alt" :"ФУТБОЛКА АНИМЕ",
"name": "ФУТБОЛКА АНИМА",
"price": "1500 руб.",
"setphoto": ["shirt10_1x","shirt10.1_1x","shirt10_2x","shirt10.1_2x", "shirt10_4x", "shirt10.1_4x"],
"size": ["XS/S","M/L","XL/XLL"],
"body": ["79276",
"Лето 2024",
"Третьяковская галерея",
"без застежки",
"фистошковый",
"100% Хлопок",
"свободный",
"картина",
"удлиненная",
"101-78-96",
"189",
"L (50)",
"без карманов",
"160",
"Мужской"]
},
{
"id": 6,
"photo": ["shirt11_1x", "shirt11.1_1x"],
"alt" :"ФУТБОЛКА ОВЕРСАЙЗ С ПРИНТОМ ЭРАРТА",
"name": "ФУТБОЛКА ОВЕРСАЙЗ С ПРИНТОМ ЭРАРТА",
"price": "1500 руб.",
"setphoto": ["shirt11_1x","shirt11.1_1x","shirt11_2x","shirt11.1_2x", "shirt11_4x", "shirt11.1_4x"],
"size": ["XS/S","M/L","XL/XLL"],
"body": ["79276",
"Лето 2024",
"Третьяковская галерея",
"без застежки",
"черный",
"100% Хлопок",
"свободный",
"картина",
"удлиненная",
"101-78-96",
"189",
"L (50)",
"без карманов",
"160",
"Женский"]
},
{
"id": 7,
"photo": ["shirt7_1x", "shirt7_1_1x"],
"alt" :"ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'",
"name": "ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'",
"price": "1500 руб.",
"color" : "Белый",
"colorid" : 1,
"colorcss": ["#606060","#FFFFFF"],
"setphoto": ["shirt7_1x","shirt7_1_1x","shirt7_2x","shirt7_1_2x", "shirt7_4x", "shirt7_1_4x"],
"size": ["XS/S","M/L","XL/XLL"],
"body": ["79653",
"Весна-Лето 2023",
"Черное море",
"без застежки",
"светло-серый",
"100% Хлопок",
"свободный",
"картина",
"удлиненная",
"101-78-96",
"178",
"M (48)",
"без карманов",
"160",
"Женский"]
} }
] ]