Merge pull request 'fixing stub paths' (#55) from kazan-explore into master

Reviewed-on: #55
This commit is contained in:
Kamila Nazirova 2024-12-27 23:01:16 +03:00
commit 2d1a4ba8db

View File

@ -5,7 +5,7 @@ const router = require('express').Router();
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'); // Загружаем весь 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) {
@ -16,7 +16,7 @@ router.get('/getInfoAboutKazan', (request, response) => {
router.get('/getNews', (request, response) => { router.get('/getNews', (request, response) => {
const lang = request.query.lang || 'ru'; const lang = request.query.lang || 'ru';
try { try {
const data = require(`../json/first/news/${lang}/success.json`); const data = require(`./json/first/news/${lang}/success.json`);
response.send(data); response.send(data);
} catch (error) { } catch (error) {
response.status(404).send({ message: 'Language not found' }); response.status(404).send({ message: 'Language not found' });
@ -27,7 +27,7 @@ router.get('/getNews', (request, response) => {
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'); // Загружаем 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) {
@ -38,7 +38,7 @@ router.get('/getFirstText', (request, response) => {
router.get('/getSecondText', (request, response) => { router.get('/getSecondText', (request, response) => {
const lang = request.query.lang || 'ru'; const lang = request.query.lang || 'ru';
try { 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']; const translatedData = data[lang] || data['ru'];
response.send(translatedData); response.send(translatedData);
} catch (error) { } catch (error) {
@ -49,7 +49,7 @@ router.get('/getSecondText', (request, response) => {
router.get('/getSportData', (request, response) => { router.get('/getSportData', (request, response) => {
const lang = request.query.lang || 'ru'; const lang = request.query.lang || 'ru';
try { try {
const data = require(`../json/sport/sport-list/${lang}/success.json`); const data = require(`./json/sport/sport-list/${lang}/success.json`);
response.send(data); response.send(data);
} catch (error) { } catch (error) {
response.status(404).send({ message: 'Language not found' }); response.status(404).send({ message: 'Language not found' });
@ -60,7 +60,7 @@ router.get('/getSportData', (request, response) => {
router.get('/getPlacesData', (request, response) => { router.get('/getPlacesData', (request, response) => {
const lang = request.query.lang || 'ru'; const lang = request.query.lang || 'ru';
try { try {
const data = require(`../json/places/${lang}/success.json`); const data = require(`./json/places/${lang}/success.json`);
response.send(data); response.send(data);
} catch (error) { } catch (error) {
response.status(404).send({ message: 'Language not found' }); response.status(404).send({ message: 'Language not found' });
@ -71,7 +71,7 @@ router.get('/getPlacesData', (request, response) => {
router.get('/getInfoAboutTransportPage', (request, response) => { router.get('/getInfoAboutTransportPage', (request, response) => {
const lang = request.query.lang || 'ru'; const lang = request.query.lang || 'ru';
try { 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']; const translatedData = data[lang] || data['ru'];
response.send(translatedData); response.send(translatedData);
} catch (error) { } catch (error) {
@ -80,21 +80,21 @@ router.get('/getInfoAboutTransportPage', (request, response) => {
}) })
router.get('/getBus', (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) => { 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) => { 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) => { router.get('/getTripSchedule', (request, response) => {
const lang = request.query.lang || 'ru'; const lang = request.query.lang || 'ru';
try { try {
const data = require(`../json/transport/trip-schedule/${lang}/success.json`); const data = require(`./json/transport/trip-schedule/${lang}/success.json`);
response.send(data); response.send(data);
} catch (error) { } catch (error) {
response.status(404).send({ message: 'Language not found' }); response.status(404).send({ message: 'Language not found' });
@ -105,7 +105,7 @@ router.get('/getTripSchedule', (request, response) => {
router.get('/getHistoryText', (request, response) => { router.get('/getHistoryText', (request, response) => {
const lang = request.query.lang || 'ru'; const lang = request.query.lang || 'ru';
try { try {
const data = require(`../json/history/text/${lang}/success.json`); const data = require(`./json/history/text/${lang}/success.json`);
response.send(data); response.send(data);
} catch (error) { } catch (error) {
response.status(404).send({ message: 'Language not found' }); response.status(404).send({ message: 'Language not found' });
@ -114,7 +114,7 @@ router.get('/getHistoryText', (request, response) => {
router.get('/getHistoryList', (request, response) => { router.get('/getHistoryList', (request, response) => {
const lang = request.query.lang || 'ru'; const lang = request.query.lang || 'ru';
try { try {
const data = require(`../json/history/list/${lang}/success.json`); const data = require(`./json/history/list/${lang}/success.json`);
response.send(data); response.send(data);
} catch (error) { } catch (error) {
response.status(404).send({ message: 'Language not found' }); response.status(404).send({ message: 'Language not found' });
@ -125,7 +125,7 @@ router.get('/getHistoryList', (request, response) => {
router.get('/getInfoAboutEducation', (request, response) => { router.get('/getInfoAboutEducation', (request, response) => {
const lang = request.query.lang || 'ru'; const lang = request.query.lang || 'ru';
try { try {
const data = require('../json/education/text/success.json'); const data = require('./json/education/text/success.json');
const translatedData = data[lang] || data['ru']; const translatedData = data[lang] || data['ru'];
response.send(translatedData); response.send(translatedData);
} catch (error) { } catch (error) {
@ -135,7 +135,7 @@ router.get('/getInfoAboutEducation', (request, response) => {
router.get('/getEducationList', (request, response) => { router.get('/getEducationList', (request, response) => {
const lang = request.query.lang || 'ru'; const lang = request.query.lang || 'ru';
try { try {
const data = require(`../json/education/cards/${lang}/success.json`); const data = require(`./json/education/cards/${lang}/success.json`);
response.send(data); response.send(data);
} catch (error) { } catch (error) {
response.status(404).send({ message: 'Language not found' }); response.status(404).send({ message: 'Language not found' });
@ -144,7 +144,7 @@ router.get('/getEducationList', (request, response) => {
router.get('/getInfoAboutKFU', (request, response) => { router.get('/getInfoAboutKFU', (request, response) => {
const lang = request.query.lang || 'ru'; const lang = request.query.lang || 'ru';
try { try {
const data = require('../json/education/kfu/success.json'); const data = require('./json/education/kfu/success.json');
const translatedData = data[lang] || data['ru']; const translatedData = data[lang] || data['ru'];
response.send(translatedData); response.send(translatedData);
} catch (error) { } catch (error) {
@ -158,7 +158,7 @@ router.post('/entrance', (request, response) => {
const { email, password } = request.body.entranceData; const { email, password } = request.body.entranceData;
try { 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); const user = users.data.find(user => user.email === email && user.password === password);
if (!user) { if (!user) {
@ -183,7 +183,7 @@ router.post('/registration', async (request, response) => {
if (password !== confirmPassword) { if (password !== confirmPassword) {
return response.status(400).send('Пароли не совпадают!'); 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); const existingUser = users.data.find(user => user.email === email);