Compare commits

..

No commits in common. "7809806b8308e9414725809ee671b7292d60c751" and "8fc85a7de8baa808fd35277b45d8b7fe554fdfc9" have entirely different histories.

6 changed files with 0 additions and 522 deletions

View File

@ -57,7 +57,6 @@ app.use('/example', require('./routers/example'))
app.use('/zoom-bar', require('./routers/zoom-bar'))
app.use('/r-and-m', require('./routers/r-and-m'))
app.use('/edateam', require('./routers/edateam'))
app.use('/webstar-project', require('./routers/webstar-project'))
//app.use('/basket', require('./routers/basket'))
//app.use('/easy-project', require('./routers/easy-project'))
//app.use('/sugarbun', require('./routers/sugarbun'))

View File

@ -1,136 +0,0 @@
const router = require('express').Router();
const authMiddleware = require('./middleware/auth-middleware');
router.get('/cards-data', (request, response) => {
response.send(require('./json/cards-data/success.json'))
})
router.get('/messages', (request, response) => {
response.send(require('./json/messages/success.json'))
})
router.get('/user', authMiddleware, (request, response) => {
const email = request.userEmail;
try {
const usersData = require('./json/users-data/success.json');
const userData = usersData.data.find(user => user.email === email);
if (userData) {
return response.json(userData.favourites);
}
response.status(404).send('User not found');
} catch (error) {
console.error('Error reading file:', error);
response.status(500).send('Internal server error');
}
})
router.get('/cards-data/:id', (request, response) => {
const cardId = request.params.id;
try {
const cardsData = require('./json/cards-data/success.json');
const cardData = cardsData.data.find(card => card.id === cardId);
if (cardData) {
return response.json(cardData);
}
response.status(404).send('Card not found');
} catch (error) {
console.error('Error reading file:', error);
response.status(500).send('Internal server error');
}
})
router.get('/messages/:id', (request, response) => {
const cardId = request.params.id;
try {
const cardsData = require('./json/messages/success.json');
const cardData = cardsData.data.find(card => card.id === cardId);
if (cardData) {
return response.json(cardData);
}
response.status(404).send('Card not found');
} catch (error) {
console.error('Error reading file:', error);
response.status(500).send('Internal server error');
}
})
router.post('/login', (request, response) => {
const { email, password } = request.body.loginData;
try {
const users = require('./json/users-data/success.json');
const user = users.data.find(user => user.email === email && user.password === password);
if (!user) {
return response.status(401).send('Invalid credentials');
}
const responseObject = {
email: user.email,
}
if (user.cardId){
responseObject.cardId = user.cardId || "";
}
return response.json(responseObject);
} catch (error) {
console.error('Error reading file:', error);
response.status(500).send('Internal server error');
}
})
router.post('/register', async (request, response) => {
const { _name, email, password, confirmPassword } = request.body.registerData;
try {
if (password !== confirmPassword) {
return response.status(400).send('Passwords do not match');
}
const users = require('./json/users-data/success.json');
const existingUser = users.data.find(user => user.email === email);
if (existingUser) {
return response.status(400).send('User with this email already exists');
}
return response.json({ email: email});
} catch (error) {
console.error('Error registering user:', error);
response.status(500).send('Internal server error');
}
});
router.post('/favourite', async (request, response) => {
const { cardId, email } = request.body;
try {
const users = require('./json/users-data/success.json');
const user = users.data.find(user => user.email === email);
if (!user) {
return response.status(404).send('User not found');
}
const index = user.favourites.indexOf(cardId);
if (index !== -1) {
return response.status(200).send('Card removed from favourites successfully');
}
response.status(200).send('Card added to favourites successfully');
} catch (error) {
console.error('Error adding card to favourites:', error);
response.status(500).send('Internal server error');
}
});
module.exports = router;

View File

@ -1,172 +0,0 @@
{
"data": [
{
"id": "1",
"ownerId": "user1@gmail.com",
"sliderImages": ["site1", "site2", "site3"],
"title": "Верстка сайтов любой сложности. Мобильная разработка",
"tags": ["Сайты", "Под ключ", "Десктоп"],
"profileData": {
"name": "Yuji Itadori",
"geolocation": "г. Казань",
"description": "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Expedita nemo cumque, magni doloremque aspernatur illo nisi magnam! Perspiciatis, aspernatur excepturi dolores autem, ut sequi dolore vitae doloremque ratione expedita velit molestias quidem hic quod culpa corrupti vel ad.",
"profilePicture": "site1",
"backgroundImage": "backgroundImage1"
},
"articles": [
{
"id": "1",
"label": "Верстка статичного сайта",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site1"
},
{
"id": "2",
"label": "Разработка простого мобильного приложения",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site2"
}
]
},
{
"id": "2",
"ownerId": "admin@admin.ru",
"sliderImages": ["site2", "site1", "site3"],
"title": "Дизайн сайтов. Разработка сайтов под ключ",
"tags": ["Сайты", "Под ключ", "Десктоп"],
"profileData": {
"name": "Admin",
"geolocation": "г. Казань",
"description": "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Expedita nemo cumque, magni doloremque aspernatur illo nisi magnam! Perspiciatis, aspernatur excepturi dolores autem, ut sequi dolore vitae doloremque ratione expedita velit molestias quidem hic quod culpa corrupti vel ad.",
"profilePicture": "site2",
"backgroundImage": "backgroundImage1"
},
"articles": [
{
"id": "1",
"label": "Верстка статичного сайта",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site1"
},
{
"id": "2",
"label": "Разработка простого мобильного приложения",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site2"
}
]
},
{
"id": "3",
"ownerId": "user2@gmail.com",
"sliderImages": ["site3", "site1", "site3"],
"title": "FullStack разработка приложений на React",
"tags": ["Сайты", "Под ключ", "Десктоп"],
"profileData": {
"name": "Secret Guest",
"geolocation": "г. Казань",
"description": "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Expedita nemo cumque, magni doloremque aspernatur illo nisi magnam! Perspiciatis, aspernatur excepturi dolores autem, ut sequi dolore vitae doloremque ratione expedita velit molestias quidem hic quod culpa corrupti vel ad.",
"profilePicture": "site3",
"backgroundImage": "backgroundImage1"
},
"articles": [
{
"id": "1",
"label": "Верстка статичного сайта",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site1"
},
{
"id": "2",
"label": "Разработка простого мобильного приложения",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site2"
}
]
},
{
"id": "4",
"ownerId": "super@star.ru",
"sliderImages": ["site1", "site1", "site3"],
"title": "Верстка сайтов любой сложности. Мобильная разработка",
"tags": ["Сайты", "Под ключ", "Десктоп"],
"profileData": {
"name": "Hatsune Miku",
"geolocation": "г. Казань",
"description": "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Expedita nemo cumque, magni doloremque aspernatur illo nisi magnam! Perspiciatis, aspernatur excepturi dolores autem, ut sequi dolore vitae doloremque ratione expedita velit molestias quidem hic quod culpa corrupti vel ad.",
"profilePicture": "site3",
"backgroundImage": "backgroundImage1"
},
"articles": [
{
"id": "1",
"label": "Верстка статичного сайта",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site1"
},
{
"id": "2",
"label": "Разработка простого мобильного приложения",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site2"
}
]
},
{
"id": "5",
"ownerId": "sb@sb.ru",
"sliderImages": ["site2", "site1", "site3"],
"title": "Дизайн сайтов. Разработка сайтов под ключ",
"tags": ["Дизайн", "Под ключ"],
"profileData": {
"name": "СберТян",
"geolocation": "г. Казань",
"description": "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Expedita nemo cumque, magni doloremque aspernatur illo nisi magnam! Perspiciatis, aspernatur excepturi dolores autem, ut sequi dolore vitae doloremque ratione expedita velit molestias quidem hic quod culpa corrupti vel ad.",
"profilePicture": "site3",
"backgroundImage": "backgroundImage1"
},
"articles": [
{
"id": "1",
"label": "Верстка статичного сайта",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site1"
},
{
"id": "2",
"label": "Разработка простого мобильного приложения",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site2"
}
]
},
{
"id": "6",
"ownerId": "tin@tin.ru",
"sliderImages": ["site3", "site1", "site3"],
"title": "FullStack разработка приложений на React",
"tags": ["Сайты", "Под ключ", "Мобильные устройства"],
"profileData": {
"name": "Помощник Олег",
"geolocation": "г. Казань",
"description": "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Expedita nemo cumque, magni doloremque aspernatur illo nisi magnam! Perspiciatis, aspernatur excepturi dolores autem, ut sequi dolore vitae doloremque ratione expedita velit molestias quidem hic quod culpa corrupti vel ad.",
"profilePicture": "site3",
"backgroundImage": "backgroundImage1"
},
"articles": [
{
"id": "1",
"label": "Верстка статичного сайта",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site1"
},
{
"id": "2",
"label": "Разработка простого мобильного приложения",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site2"
}
]
}
]
}

View File

@ -1,149 +0,0 @@
{
"data": [
{
"id": "1",
"ownerId": "user1@gmail.ru",
"onModerating": true,
"sliderImages": ["site1", "site2", "site3"],
"title": "Верстка сайтов любой сложности. Мобильная разработка",
"tags": ["Сайты", "Под ключ", "Десктоп"],
"profileData": {
"name": "Yuji Itadori",
"geolocation": "г. Казань",
"description": "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Expedita nemo cumque, magni doloremque aspernatur illo nisi magnam! Perspiciatis, aspernatur excepturi dolores autem, ut sequi dolore vitae doloremque ratione expedita velit molestias quidem hic quod culpa corrupti vel ad.",
"profilePicture": "site2",
"backgroundImage": "backgroundImage1"
},
"articles": [
{
"id": "1",
"label": "Верстка статичного сайта",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site1"
},
{
"id": "2",
"label": "Разработка простого мобильного приложения",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site2"
}
]
},
{
"id": "2",
"ownerId": "admin@admin.ru",
"onModerating": true,
"sliderImages": ["site2", "site1", "site3"],
"title": "Дизайн сайтов. Разработка сайтов под ключ",
"tags": ["Сайты", "Под ключ", "Десктоп"],
"profileData": {
"name": "Admin",
"geolocation": "г. Казань",
"description": "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Expedita nemo cumque, magni doloremque aspernatur illo nisi magnam! Perspiciatis, aspernatur excepturi dolores autem, ut sequi dolore vitae doloremque ratione expedita velit molestias quidem hic quod culpa corrupti vel ad.",
"profilePicture": "profilePicture1",
"backgroundImage": "backgroundImage1"
},
"articles": [
{
"id": "1",
"label": "Верстка статичного сайта",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site1"
},
{
"id": "2",
"label": "Разработка простого мобильного приложения",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site2"
}
]
},
{
"id": "3",
"ownerId": "user2@gmail.com",
"onModerating": true,
"sliderImages": ["site3", "site1", "site3"],
"title": "FullStack разработка приложений на React",
"tags": ["Сайты", "Под ключ", "Десктоп"],
"profileData": {
"name": "Secret Guest",
"geolocation": "г. Казань",
"description": "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Expedita nemo cumque, magni doloremque aspernatur illo nisi magnam! Perspiciatis, aspernatur excepturi dolores autem, ut sequi dolore vitae doloremque ratione expedita velit molestias quidem hic quod culpa corrupti vel ad.",
"profilePicture": "profilePicture1",
"backgroundImage": "backgroundImage1"
},
"articles": [
{
"id": "1",
"label": "Верстка статичного сайта",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site1"
},
{
"id": "2",
"label": "Разработка простого мобильного приложения",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site2"
}
]
},
{
"id": "4",
"ownerId": "super@star.ru",
"onModerating": true,
"sliderImages": ["site1", "site1", "site3"],
"title": "Верстка сайтов любой сложности. Мобильная разработка",
"tags": ["Сайты", "Под ключ", "Десктоп"],
"profileData": {
"name": "Hatsune Miku",
"geolocation": "г. Казань",
"description": "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Expedita nemo cumque, magni doloremque aspernatur illo nisi magnam! Perspiciatis, aspernatur excepturi dolores autem, ut sequi dolore vitae doloremque ratione expedita velit molestias quidem hic quod culpa corrupti vel ad.",
"profilePicture": "profilePicture1",
"backgroundImage": "backgroundImage1"
},
"articles": [
{
"id": "1",
"label": "Верстка статичного сайта",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site1"
},
{
"id": "2",
"label": "Разработка простого мобильного приложения",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site2"
}
]
},
{
"id": "5",
"ownerId": "sb@sb.ru",
"onModerating": false,
"sliderImages": ["site2", "site1", "site3"],
"title": "Дизайн сайтов. Разработка сайтов под ключ",
"tags": ["Дизайн", "Под ключ"],
"profileData": {
"name": "СберТян",
"geolocation": "г. Казань",
"description": "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Expedita nemo cumque, magni doloremque aspernatur illo nisi magnam! Perspiciatis, aspernatur excepturi dolores autem, ut sequi dolore vitae doloremque ratione expedita velit molestias quidem hic quod culpa corrupti vel ad.",
"profilePicture": "profilePicture1",
"backgroundImage": "backgroundImage1"
},
"articles": [
{
"id": "1",
"label": "Верстка статичного сайта",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site1"
},
{
"id": "2",
"label": "Разработка простого мобильного приложения",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",
"imageUrl": "site2"
}
]
}
]
}

View File

@ -1,50 +0,0 @@
{
"data": [
{
"name": "Yuji Itadori",
"email": "user1@gmail.com",
"password": "12345",
"cardId": "1",
"favourites": [
"1",
"2",
"6"
]
},
{
"name": "Admin",
"email": "admin@admin.ru",
"password": "*****",
"cardId": "2",
"favourites": []
},
{
"name": "Secret Guest",
"email": "user2@gmail.com",
"password": "qwer",
"cardId": "3",
"favourites": []
},
{
"name": "Hatsune Miku",
"email": "super@star.ru",
"password": "12345",
"cardId": "4",
"favourites": []
},
{
"name": "СберТян",
"email": "sb@sb.ru",
"password": "12345",
"cardId": "5",
"favourites": []
},
{
"name": "Помощник Олег",
"email": "tin@tin.ru",
"password": "12345",
"cardId": "6",
"favourites": []
}
]
}

View File

@ -1,14 +0,0 @@
const authMiddleware = (req, res, next) => {
const email = (req.headers.authorization || "").replace("Bearer ", "");
if (email) {
req.userEmail = email;
next();
} else {
return res.status(403).json({
message: "Access Denied",
});
}
};
module.exports = authMiddleware