From 298a82e0ae7f15ef8fbf7c3316992eece3da9914 Mon Sep 17 00:00:00 2001 From: Kamila Nazirova Date: Fri, 24 Jan 2025 23:02:25 +0300 Subject: [PATCH] kazan-explore multy stub changes --- .../routers/kazan-explore/{api => }/const.js | 0 .../routers/kazan-explore/{api => }/index.js | 52 +++++++++---------- .../kazan-explore/{api => }/model/results.js | 0 3 files changed, 26 insertions(+), 26 deletions(-) rename server/routers/kazan-explore/{api => }/const.js (100%) rename server/routers/kazan-explore/{api => }/index.js (73%) rename server/routers/kazan-explore/{api => }/model/results.js (100%) diff --git a/server/routers/kazan-explore/api/const.js b/server/routers/kazan-explore/const.js similarity index 100% rename from server/routers/kazan-explore/api/const.js rename to server/routers/kazan-explore/const.js diff --git a/server/routers/kazan-explore/api/index.js b/server/routers/kazan-explore/index.js similarity index 73% rename from server/routers/kazan-explore/api/index.js rename to server/routers/kazan-explore/index.js index 9286438..b74f5b5 100644 --- a/server/routers/kazan-explore/api/index.js +++ b/server/routers/kazan-explore/index.js @@ -42,20 +42,20 @@ router.post('/addQuizResult', async (request, response) => { // First page router.get('/getInfoAboutKazan', (request, response) => { - const lang = request.query.lang || 'ru'; // Получаем язык из параметров запроса + const lang = request.query.lang || 'ru'; try { - const data = require('../json/first/info-about-kazan/success.json'); // Загружаем весь JSON - const translatedData = data[lang] || data['ru']; // Выбираем перевод по языку или дефолтный - response.send(translatedData); // Отправляем перевод клиенту + const data = require('./json/first/info-about-kazan/success.json'); + const translatedData = data[lang] || data['ru']; + response.send(translatedData); } catch (error) { - response.status(500).send({ message: 'Internal server error' }); // Ошибка в случае проблем с JSON + response.status(500).send({ message: 'Internal server error' }); } }); router.get('/getNews', (request, response) => { const lang = request.query.lang || 'ru'; try { - const data = require(`../json/first/news/${lang}/success.json`); + const data = require(`./json/first/news/${lang}/success.json`); response.send(data); } catch (error) { response.status(404).send({ message: 'Language not found' }); @@ -64,20 +64,20 @@ router.get('/getNews', (request, response) => { // Sport page router.get('/getFirstText', (request, response) => { - const lang = request.query.lang || 'ru'; // Получаем язык из параметров + const lang = request.query.lang || 'ru'; try { - const data = require('../json/sport/first-text/success.json'); // Загружаем JSON - const translatedData = data[lang] || data['ru']; // Берём перевод или дефолтный + const data = require('./json/sport/first-text/success.json'); + const translatedData = data[lang] || data['ru']; response.send(translatedData); } catch (error) { - response.status(404).send({ message: 'Language not found' }); // Обработка ошибки + response.status(404).send({ message: 'Language not found' }); } }); router.get('/getSecondText', (request, response) => { const lang = request.query.lang || 'ru'; try { - const data = require('../json/sport/second-text/success.json'); + const data = require('./json/sport/second-text/success.json'); const translatedData = data[lang] || data['ru']; response.send(translatedData); } catch (error) { @@ -88,7 +88,7 @@ router.get('/getSecondText', (request, response) => { router.get('/getSportData', (request, response) => { const lang = request.query.lang || 'ru'; try { - const data = require(`../json/sport/sport-list/${lang}/success.json`); + const data = require(`./json/sport/sport-list/${lang}/success.json`); response.send(data); } catch (error) { response.status(404).send({ message: 'Language not found' }); @@ -98,7 +98,7 @@ router.get('/getSportData', (request, response) => { router.get('/getSportQuiz', (request, response) => { const lang = request.query.lang || 'ru'; try { - const data = require(`../json/sport/quiz/${lang}/success.json`); + const data = require(`./json/sport/quiz/${lang}/success.json`); response.send(data); } catch (error) { response.status(404).send({ message: 'Language not found' }); @@ -109,7 +109,7 @@ router.get('/getSportQuiz', (request, response) => { router.get('/getPlacesData', (request, response) => { const lang = request.query.lang || 'ru'; try { - const data = require(`../json/places/${lang}/success.json`); + const data = require(`./json/places/${lang}/success.json`); response.send(data); } catch (error) { response.status(404).send({ message: 'Language not found' }); @@ -120,7 +120,7 @@ router.get('/getPlacesData', (request, response) => { router.get('/getInfoAboutTransportPage', (request, response) => { const lang = request.query.lang || 'ru'; try { - const data = require('../json/transport/info-about-page/success.json'); + const data = require('./json/transport/info-about-page/success.json'); const translatedData = data[lang] || data['ru']; response.send(translatedData); } catch (error) { @@ -129,21 +129,21 @@ router.get('/getInfoAboutTransportPage', (request, response) => { }) router.get('/getBus', (request, response) => { - response.send(require('../json/transport/bus-numbers/success.json')) + response.send(require('./json/transport/bus-numbers/success.json')) }) router.get('/getTral', (request, response) => { - response.send(require('../json/transport/tral-numbers/success.json')) + response.send(require('./json/transport/tral-numbers/success.json')) }) router.get('/getEvents', (request, response) => { - response.send(require('../json/transport/events-calendar/success.json')) + response.send(require('./json/transport/events-calendar/success.json')) }) router.get('/getTripSchedule', (request, response) => { const lang = request.query.lang || 'ru'; try { - const data = require(`../json/transport/trip-schedule/${lang}/success.json`); + const data = require(`./json/transport/trip-schedule/${lang}/success.json`); response.send(data); } catch (error) { response.status(404).send({ message: 'Language not found' }); @@ -154,7 +154,7 @@ router.get('/getTripSchedule', (request, response) => { router.get('/getHistoryText', (request, response) => { const lang = request.query.lang || 'ru'; try { - const data = require(`../json/history/text/${lang}/success.json`); + const data = require(`./json/history/text/${lang}/success.json`); response.send(data); } catch (error) { response.status(404).send({ message: 'Language not found' }); @@ -163,7 +163,7 @@ router.get('/getHistoryText', (request, response) => { router.get('/getHistoryList', (request, response) => { const lang = request.query.lang || 'ru'; try { - const data = require(`../json/history/list/${lang}/success.json`); + const data = require(`./json/history/list/${lang}/success.json`); response.send(data); } catch (error) { response.status(404).send({ message: 'Language not found' }); @@ -174,7 +174,7 @@ router.get('/getHistoryList', (request, response) => { router.get('/getInfoAboutEducation', (request, response) => { const lang = request.query.lang || 'ru'; try { - const data = require('../json/education/text/success.json'); + const data = require('./json/education/text/success.json'); const translatedData = data[lang] || data['ru']; response.send(translatedData); } catch (error) { @@ -184,7 +184,7 @@ router.get('/getInfoAboutEducation', (request, response) => { router.get('/getEducationList', (request, response) => { const lang = request.query.lang || 'ru'; try { - const data = require(`../json/education/cards/${lang}/success.json`); + const data = require(`./json/education/cards/${lang}/success.json`); response.send(data); } catch (error) { response.status(404).send({ message: 'Language not found' }); @@ -193,7 +193,7 @@ router.get('/getEducationList', (request, response) => { router.get('/getInfoAboutKFU', (request, response) => { const lang = request.query.lang || 'ru'; try { - const data = require('../json/education/kfu/success.json'); + const data = require('./json/education/kfu/success.json'); const translatedData = data[lang] || data['ru']; response.send(translatedData); } catch (error) { @@ -207,7 +207,7 @@ router.post('/entrance', (request, response) => { const { email, password } = request.body.entranceData; try { - const users = require('../json/users-information/success.json'); + const users = require('./json/users-information/success.json'); const user = users.data.find(user => user.email === email && user.password === password); if (!user) { @@ -232,7 +232,7 @@ router.post('/registration', async (request, response) => { if (password !== confirmPassword) { return response.status(400).send('Пароли не совпадают!'); } - const users = require('../json/users-information/success.json'); + const users = require('./json/users-information/success.json'); const existingUser = users.data.find(user => user.email === email); diff --git a/server/routers/kazan-explore/api/model/results.js b/server/routers/kazan-explore/model/results.js similarity index 100% rename from server/routers/kazan-explore/api/model/results.js rename to server/routers/kazan-explore/model/results.js