Compare commits
243
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
312cc229d8 | ||
|
|
11b1d670d0 | ||
|
|
522ea36bb9 | ||
|
|
8be391c8e1 | ||
|
|
ea80304c21 | ||
|
|
771f75ef08 | ||
|
|
edf9b2c82b | ||
|
|
8c3bf8a8ed | ||
|
|
a88d3657bf | ||
|
|
1656ce8690 | ||
|
|
7cdbec53ee | ||
|
|
eee00f0797 | ||
|
|
33845b743d | ||
|
|
059139e213 | ||
|
|
005e7a0ac9 | ||
|
|
9ee59256a9 | ||
|
|
c2784dcf45 | ||
|
|
64ed9b8eda | ||
|
|
e9814f36bf | ||
|
|
0bd883df59 | ||
|
|
1657b0c5e9 | ||
|
|
a9673b260f | ||
|
|
8ee5ca5528 | ||
|
|
e1e335098e | ||
|
|
619975d1e0 | ||
|
|
f29bc83d56 | ||
|
|
61347d1aee | ||
|
|
ac7a99ef15 | ||
|
|
eb3f1f7e3f | ||
|
|
3e02ea5843 | ||
|
|
d06aeeb246 | ||
|
|
e331f69885 | ||
|
|
23f1277edb | ||
|
|
801f9ac1e3 | ||
|
|
16bffcafa6 | ||
|
|
922909397d | ||
|
|
233192ba01 | ||
|
|
f72d5220de | ||
|
|
30af0fb1dd | ||
|
|
854e249100 | ||
|
|
eddad1cc3f | ||
|
|
c96e435344 | ||
|
|
7358faef1d | ||
|
|
68de877b06 | ||
|
|
c000106ec8 | ||
|
|
da84344a63 | ||
|
|
daf5bf7970 | ||
|
|
4ef941d62f | ||
|
|
16fda2e7ed | ||
|
|
ff15a48414 | ||
|
|
367c0de6fb | ||
|
|
3c89d8b9a8 | ||
|
|
bdc8d9a8e0 | ||
|
|
cbbb376fd6 | ||
|
|
faaec7c718 | ||
|
|
8814c2a64b | ||
|
|
298a82e0ae | ||
|
|
a86eb0d4ef | ||
|
|
335179ad26 | ||
|
|
a1d331b5b4 | ||
|
|
4b77958a92 | ||
|
|
b36ee36e3a | ||
|
|
48ffee1a78 | ||
|
|
6e0934e585 | ||
|
|
846db377ef | ||
|
|
3e8a8997b9 | ||
|
|
04bce4b90f | ||
|
|
3d935af6f1 | ||
|
|
0d5dc115b6 | ||
|
|
15cfc129a5 | ||
|
|
270fe51500 | ||
|
|
8a2afc3f1b | ||
|
|
d824844ae5 | ||
|
|
f95a26acbb | ||
|
|
e0618e431f | ||
|
|
1b93a8e2bb | ||
|
|
b8dc15cbc6 | ||
|
|
949416d2a3 | ||
|
|
1ec9f1a7ec | ||
|
|
17c63e6fe0 | ||
|
|
87c1cbb19e | ||
|
|
c86f84d037 | ||
|
|
b8bc2c83a3 | ||
|
|
552457b5cb | ||
|
|
909f7e4de9 | ||
|
|
86b79a7f49 | ||
|
|
d2d8b63aba | ||
|
|
0dcf961cce | ||
|
|
38bc0c55c8 | ||
|
|
9fb4219418 | ||
|
|
fb644b6f7b | ||
|
|
d88e680413 | ||
|
|
8b7f43d15a | ||
|
|
b9edd0091c | ||
|
|
558245f876 | ||
|
|
a927727c1b | ||
|
|
a9d9aa02da | ||
|
|
e7451aea5b | ||
|
|
5cc580c3c5 | ||
|
|
3fe62ec268 | ||
|
|
e73f7e2dc9 | ||
|
|
571c43c33c | ||
|
|
61c847b58c | ||
|
|
4d621c8bbe | ||
|
|
ab8a9ebc99 | ||
|
|
2d1a4ba8db | ||
|
|
9ed6808838 | ||
|
|
8bd3ccfce7 | ||
|
|
9818550b29 | ||
|
|
fe8a477b27 | ||
|
|
12af9b7c10 | ||
|
|
1871f3f96a | ||
|
|
05be7c4a26 | ||
|
|
46c8147172 | ||
|
|
271f7cab7d | ||
|
|
50e105b851 | ||
|
|
da201720c0 | ||
|
|
b3fd86da33 | ||
|
|
276ef4033b | ||
|
|
a520692bc5 | ||
|
|
a327c9caeb | ||
|
|
9a8fddee3b | ||
|
|
149d668bea | ||
|
|
5d08c4c1c2 | ||
|
|
2356259823 | ||
|
|
872c921a53 | ||
|
|
10b5207f9a | ||
|
|
2ede62bcd8 | ||
|
|
1788f90cde | ||
|
|
a37f7ea8a8 | ||
|
|
18b63bed21 | ||
|
|
707c3be3ec | ||
|
|
3d52ef9d4c | ||
|
|
42944af2d3 | ||
|
|
f0f6b78cd0 | ||
|
|
7c35f17008 | ||
|
|
0208e29ae3 | ||
|
|
4d5cd104ad | ||
|
|
6702473053 | ||
|
|
52083097a2 | ||
|
|
f7ac265e3b | ||
|
|
d46841c21f | ||
|
|
c95b015094 | ||
|
|
940349af29 | ||
|
|
268824c108 | ||
|
|
550554a7a5 | ||
|
|
f5a8585845 | ||
|
|
1e67f25066 | ||
|
|
359a136dbf | ||
|
|
bbc315e270 | ||
|
|
fbb5d26c8f | ||
|
|
9d3edcf0dd | ||
|
|
57eb548d6c | ||
|
|
34d2889c1d | ||
|
|
afc782f50f | ||
|
|
ff6e688206 | ||
|
|
4b0d9b4dbc | ||
|
|
2cfcd7347b | ||
|
|
c1fe275532 | ||
|
|
de46e9bf50 | ||
|
|
76558a7eef | ||
|
|
4bf3d662ec | ||
|
|
637939e9af | ||
|
|
02891fe301 | ||
|
|
6015bce32f | ||
|
|
528b37246b | ||
|
|
0c693e1bac | ||
|
|
c77aa76645 | ||
|
|
8a0ea25029 | ||
|
|
6fb3f3f921 | ||
|
|
89c9d7f901 | ||
|
|
b215e22f53 | ||
|
|
f13ae33cb4 | ||
|
|
18a1095cf0 | ||
|
|
3e27c0110c | ||
|
|
c2ada9072f | ||
|
|
1bd1d2b279 | ||
|
|
7b1ce2ae83 | ||
|
|
de22881c28 | ||
|
|
20d370f120 | ||
|
|
85986d1844 | ||
|
|
dccf769477 | ||
|
|
d088ef7af8 | ||
|
|
fad8cdfe08 | ||
|
|
a55e6d2ab2 | ||
|
|
eb6da8aa1b | ||
|
|
19a55f57c0 | ||
|
|
b649e86a43 | ||
|
|
c53f016eec | ||
|
|
0a7cbc3434 | ||
|
|
279650db25 | ||
|
|
2d45b4af72 | ||
|
|
bd4de9d7ba | ||
|
|
10dbe5c147 | ||
|
|
435f17ee22 | ||
|
|
677dc3dc29 | ||
|
|
88e3fe4172 | ||
|
|
21dcc8bbec | ||
|
|
4778dba7ed | ||
|
|
07a02ade1f | ||
|
|
311846f92d | ||
|
|
ebd561098f | ||
|
|
b4372eb53a | ||
|
|
bdb6b4ca3e | ||
|
|
426cb70eb6 | ||
|
|
61441e21b8 | ||
|
|
a6f61ba033 | ||
|
|
8588a7fa38 | ||
|
|
c35185ea32 | ||
|
|
78a332732d | ||
|
|
5f54355b97 | ||
|
|
4efbb56905 | ||
|
|
50c6286190 | ||
|
|
de29da93ba | ||
|
|
7cdd7e790f | ||
|
|
569b1b0d9e | ||
|
|
272961c583 | ||
|
|
63284d6c08 | ||
|
|
cb56e2dd2c | ||
|
|
325e2f125b | ||
|
|
786085d4d0 | ||
|
|
c95a00fb19 | ||
|
|
95373069da | ||
|
|
b8275a4c8f | ||
|
|
fb868bfefc | ||
|
|
086c94c58a | ||
|
|
812a95dd85 | ||
|
|
85ee64e92b | ||
|
|
eb87f400ee | ||
|
|
92cabfa048 | ||
|
|
b2a853e183 | ||
|
|
0a6d50cb60 | ||
|
|
7809806b83 | ||
|
|
1aa0c36c84 | ||
|
|
7c3132c54b | ||
|
|
8fc85a7de8 | ||
|
|
cb8b2cc5aa | ||
|
|
6651215eeb | ||
|
|
80f8cef142 | ||
|
|
5a57291523 | ||
|
|
39ab269f07 | ||
|
|
7cb23080bf | ||
|
|
d74e4a8624 |
No files matched your search
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,7 @@
|
||||
const ObjectId = require('mongodb').ObjectID
|
||||
const getHash = require('pbkdf2-password')()
|
||||
|
||||
const { getDB } = require('../../utils/mongo')
|
||||
const { getDB } = require('../../../utils/mongo')
|
||||
|
||||
const USERS_COLLECTION = 'users'
|
||||
const LISTS_COLLECTION = 'lists'
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,4 @@
|
||||
const { getDB } = require('../../utils/mongo')
|
||||
const { getDB } = require('../../../utils/mongo')
|
||||
|
||||
let db = null
|
||||
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,6 @@
|
||||
const router = require('express').Router();
|
||||
|
||||
const { getResponse } = require('../../../utils/common');
|
||||
const { getResponse } = require('../../../../utils/common');
|
||||
const {
|
||||
getTags,
|
||||
connect,
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,7 @@
|
||||
const { v4: uuid } = require('uuid')
|
||||
const ObjectId = require('mongodb').ObjectID
|
||||
|
||||
const { getDB } = require('../../utils/mongo')
|
||||
const { getDB } = require('../../../utils/mongo')
|
||||
const { _idToId, checkDB, _idToIdArray, filterId } = require('./utils')
|
||||
|
||||
let db = null
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,36 @@
|
||||
const router = require('express').Router();
|
||||
const checkPassword = require('pbkdf2-password')();
|
||||
const jwt = require('jsonwebtoken');
|
||||
const {EDATEAM_JWT_TOKEN} = require('./key');
|
||||
|
||||
const {getUser, _idToId, getResponse, requiredFields, signUp} = require('./controllers');
|
||||
|
||||
router.post('/sign-in', requiredFields(['email','password']), async (req, res)=>{
|
||||
try{
|
||||
const user = await getUser(req.body);
|
||||
|
||||
checkPassword({password:req.body.password, salt:user.salt},async(err, pass, salt, hash )=>{
|
||||
if(err){
|
||||
throw new Error(err);
|
||||
}
|
||||
|
||||
if(user.password === hash){
|
||||
const {password, salt:_salt, ...rest} = user;
|
||||
const token = jwt.sign(_idToId(rest), EDATEAM_JWT_TOKEN);
|
||||
return res.send(getResponse(null, token));
|
||||
}
|
||||
return res.status(400).send(getResponse('Wrong email or password!'));
|
||||
} )
|
||||
}
|
||||
catch(error){
|
||||
res.status(400).send(getResponse(error.message));
|
||||
}
|
||||
});
|
||||
|
||||
router.post('/sign-up', requiredFields(['email', 'login', 'password']), async (req, res) => {
|
||||
let error = null
|
||||
const data = await signUp(req.body).catch((e) => error = e.message)
|
||||
return res.status(error ? 400 : 200).send(getResponse(error, data))
|
||||
})
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,217 @@
|
||||
const ObjectId = require('mongodb').ObjectId;
|
||||
const getHash = require('pbkdf2-password')();
|
||||
const { getDB } = require('../../../utils/mongo');
|
||||
|
||||
const USERS_COLLECTION = 'users';
|
||||
const RECIPES_COLLECTION = 'recipes_collection';
|
||||
const FAVORITES_USER = 'favorites_user'
|
||||
let db =null;
|
||||
|
||||
const connect = async () => {
|
||||
db = await getDB('edateam');
|
||||
};
|
||||
|
||||
const init = async () => {
|
||||
await connect();
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
const _idToId = (data) => {
|
||||
const { _id, ...rest } = data;
|
||||
return {
|
||||
id: _id,
|
||||
...rest
|
||||
};
|
||||
}
|
||||
|
||||
const _idToArray = (data) => {
|
||||
const _idToMap = data.map((item) => _idToId(item));
|
||||
return _idToMap;
|
||||
}
|
||||
|
||||
const getResponse = (error, data, success = true) => {
|
||||
if (error) {
|
||||
return {
|
||||
success: false,
|
||||
error,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
success,
|
||||
data,
|
||||
}
|
||||
}
|
||||
|
||||
const signUp = async ({ email, login, password }) => {
|
||||
try {
|
||||
db = await getDB('edateam');
|
||||
const userCollection = db.collection(USERS_COLLECTION);
|
||||
|
||||
const userData = await userCollection.findOne({
|
||||
$or: [
|
||||
{ login },
|
||||
{ email }
|
||||
]
|
||||
})
|
||||
|
||||
if (userData?.login === login) {
|
||||
throw new Error('This login already in db!\nPlease come up with another login!');
|
||||
}
|
||||
|
||||
if (userData?.email === email) {
|
||||
throw new Error('This email already in db!\nPlease come up with another email!');
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
getHash({ password }, async (err, pass, salt, hash) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
const insertedCount = await userCollection.insertOne({ email, login, password: hash, salt });
|
||||
|
||||
if (!insertedCount) {
|
||||
return reject(new Error('Insert error!'));
|
||||
}
|
||||
resolve({});
|
||||
});
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const getUser = async ({ email }) => {
|
||||
if (db === null) {
|
||||
throw new Error('no db connection :((');
|
||||
}
|
||||
|
||||
try {
|
||||
const userCollection = db.collection(USERS_COLLECTION);
|
||||
const userData = await userCollection.findOne({ email });
|
||||
if (userData) {
|
||||
return userData;
|
||||
}
|
||||
throw new Error('Wrong email or password!');
|
||||
} catch (error) {
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
const getListRecipes = async () => {
|
||||
try {
|
||||
db = await getDB('edateam');
|
||||
const recipesCollection = db.collection(RECIPES_COLLECTION);
|
||||
const recipesData = await recipesCollection.find().toArray();
|
||||
|
||||
if (recipesData.length > 0) {
|
||||
return _idToArray(recipesData);
|
||||
} else {
|
||||
throw new Error('No recipes found in the database!');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error in getListRecipes:', error.message);
|
||||
throw new Error(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
const getRecipe = async (dishId ) => {
|
||||
try {
|
||||
db = await getDB('edateam');
|
||||
const recipesCollection = db.collection(RECIPES_COLLECTION);
|
||||
const id = dishId.id;
|
||||
const recipeData = await recipesCollection.findOne({ _id :new ObjectId(id) } );
|
||||
if (recipeData!=null) {
|
||||
return _idToId(recipeData);
|
||||
}
|
||||
|
||||
throw new Error('Not found recipe');
|
||||
} catch (error) {
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
const addRecipe = async (recipe) => {
|
||||
try {
|
||||
db = await getDB('edateam');
|
||||
const recipesCollection = db.collection(RECIPES_COLLECTION);
|
||||
const result = await recipesCollection.insertOne(recipe);
|
||||
|
||||
if (!result.insertedId) {
|
||||
throw new Error('Recipe insertion failed');
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
id: result.insertedId
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error in addRecipe:', error.message);
|
||||
throw new Error(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const requiredFields = (fields) => (req, res, next) => {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const fieldName of fields) {
|
||||
if (!req.body[fieldName]) {
|
||||
throw new Error(`Параметр ${fieldName} не установлен`)
|
||||
}
|
||||
}
|
||||
|
||||
next()
|
||||
}
|
||||
|
||||
const addFavorite = async (userId, recipeId) => {
|
||||
|
||||
try {
|
||||
db = await getDB('edateam');
|
||||
const favoritesCollection = db.collection(FAVORITES_USER);
|
||||
const result = await favoritesCollection.updateOne(
|
||||
{ userId: new ObjectId(userId) },
|
||||
{ $addToSet: { favorites: new ObjectId(recipeId) } },
|
||||
{ upsert: true }
|
||||
);
|
||||
return result;
|
||||
} catch (error) {
|
||||
throw new Error('Error adding favorite: ' + error.message);
|
||||
}
|
||||
};
|
||||
|
||||
const getFavorites = async (userId) => {
|
||||
try {
|
||||
db = await getDB('edateam');
|
||||
const favoritesCollection = db.collection(FAVORITES_USER);
|
||||
const userFavorites = await favoritesCollection.findOne({ userId: new ObjectId(userId) });
|
||||
|
||||
if (!userFavorites || !userFavorites.favorites || userFavorites.favorites.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const recipesCollection = db.collection(RECIPES_COLLECTION);
|
||||
const favoriteRecipes = await recipesCollection.find({ _id: { $in: userFavorites.favorites } }).toArray();
|
||||
|
||||
return favoriteRecipes;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw new Error("Failed to get user favorites with recipes");
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getUser,
|
||||
signUp,
|
||||
getResponse,
|
||||
_idToId,
|
||||
_idToArray,
|
||||
getListRecipes,
|
||||
getRecipe,
|
||||
addRecipe,
|
||||
requiredFields,
|
||||
getFavorites,
|
||||
addFavorite
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
const router = require('express').Router();
|
||||
|
||||
router.get('/recipe-data', (request, response) => {
|
||||
response.send(require('../json/recipe-data/success.json'));
|
||||
});
|
||||
|
||||
router.get('/userpage-data', (req, res) => {
|
||||
res.send(require('../json/userpage-data/success.json'));
|
||||
});
|
||||
|
||||
router.post('/userpage-data', (req, res) => {
|
||||
res.send(require('../json/userpage-data/success.json'));
|
||||
});
|
||||
|
||||
router.get('/homepage-data', (req, res) => {
|
||||
res.send(require('../json/homepage-data/success.json'));
|
||||
});
|
||||
|
||||
router.use('/auth', require('./auth'));
|
||||
|
||||
router.use('/recipe', require('./user'));
|
||||
|
||||
router.use('/main', require('./main'));
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"src": "pancakes_meat",
|
||||
"alt": "Фотография блинчиков с мясом, сыром и луком",
|
||||
"href": "?=dish01",
|
||||
"name": "Блинчики с мясом, сыром и лучком"
|
||||
},
|
||||
{
|
||||
"src": "cheesecakes",
|
||||
"alt": "Фотография сырников из творога",
|
||||
"href": "?=dish02",
|
||||
"name": "Сырники из творога"
|
||||
},
|
||||
{
|
||||
"src": "borsch",
|
||||
"alt": "Фотография борща",
|
||||
"href": "?=dish03",
|
||||
"name": "Борщ"
|
||||
},
|
||||
{
|
||||
"src": "vareniki",
|
||||
"alt": "Фотография вареников",
|
||||
"href": "?=dish04",
|
||||
"name": "Ленивые вареники"
|
||||
},
|
||||
{
|
||||
"src": "rice_porridge",
|
||||
"alt": "Фотография рисовой каши",
|
||||
"href": "?=dish05",
|
||||
"name": "Рисовая каша"
|
||||
},
|
||||
{
|
||||
"src": "cutlets",
|
||||
"alt": "Фотография котлет по-киевски",
|
||||
"href": "?=dish06",
|
||||
"name": "Котлеты по-киевски"
|
||||
},
|
||||
{
|
||||
"src": "draniki",
|
||||
"alt": "Фотография драников",
|
||||
"href": "?=dish07",
|
||||
"name": "Драники"
|
||||
},
|
||||
{
|
||||
"src": "meringue",
|
||||
"alt": "Фотография безе",
|
||||
"href": "?=dish08",
|
||||
"name": "Безе"
|
||||
},
|
||||
{
|
||||
"src": "goulash",
|
||||
"alt": "Фотография гуляша",
|
||||
"href": "?=dish09",
|
||||
"name": "Гуляш"
|
||||
},
|
||||
{
|
||||
"src": "pancakes_cherries",
|
||||
"alt": "Фотография блинчиков с вишней и творожным сыром",
|
||||
"href": "?=dish10",
|
||||
"name": "Блинчики с вишней и творожным сыром"
|
||||
},
|
||||
{
|
||||
"src": "canned_soup",
|
||||
"alt": "Фотография супа из рыбных консервов",
|
||||
"href": "?=dish11",
|
||||
"name": "Суп из рыбных консервов"
|
||||
},
|
||||
{
|
||||
"src": "salad",
|
||||
"alt": "Фотография салата",
|
||||
"href": "?=dish12",
|
||||
"name": "Салат \"Весенний\""
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name":"Блинчики с вишней и творожным сыром",
|
||||
|
||||
"stages":
|
||||
[
|
||||
"Смешать муку, молоко, яйца, сахар и соль в миске",
|
||||
"Добавить вишню в тесто и перемешать",
|
||||
"Вылить тесто на разогретую сковороду и обжарить с двух сторон до золотистого цвета",
|
||||
"Подавать блинчики, украсив творожным сыром сверху"
|
||||
],
|
||||
|
||||
"table":
|
||||
[
|
||||
{ "ingredient": "1",
|
||||
"weight": "500 гр",
|
||||
"price1": "500р.",
|
||||
"price2": "439р.",
|
||||
"price3": "600р." },
|
||||
|
||||
{ "ingredient": "Ингредиент 2",
|
||||
"weight": "2 шт",
|
||||
"price1": "120р.",
|
||||
"price2": "150р.",
|
||||
"price3": "130р." },
|
||||
|
||||
{ "ingredient": "Ингредиент 3",
|
||||
"weight": "500 гр",
|
||||
"price1": "12р.",
|
||||
"price2": "12.99р.",
|
||||
"price3": "10р." },
|
||||
|
||||
{ "ingredient": "Ингредиент 4",
|
||||
"weight": "500 гр",
|
||||
"price1": "500р.",
|
||||
"price2": "439р.",
|
||||
"price3": "600р." },
|
||||
|
||||
{ "ingredient": "Ингредиент 5",
|
||||
"weight": "500 гр",
|
||||
"price1": "500р.",
|
||||
"price2": "439р.",
|
||||
"price3": "600р." },
|
||||
|
||||
{ "ingredient": "Ингредиент 6",
|
||||
"weight": "500 гр",
|
||||
"price1": "500р.",
|
||||
"price2": "439р.",
|
||||
"price3": "600р." }
|
||||
],
|
||||
|
||||
"tags":
|
||||
[
|
||||
{ "name": "#блины", "href": "#01" },
|
||||
{ "name": "#вишня", "href": "#02" },
|
||||
{ "name": "#молоко"," href": "#03" }
|
||||
]
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"data":{
|
||||
"id":1,
|
||||
"loginname":"Логин пользователя",
|
||||
"datesignin":"2024/05/18",
|
||||
"favoritedishes":
|
||||
[
|
||||
{"id":1,
|
||||
"dishlink":"?=dish1",
|
||||
"dishname":"Блюдо1"
|
||||
},
|
||||
{"id":2,
|
||||
"dishlink":"?=dish2",
|
||||
"dishname":"Блюдо2"
|
||||
},
|
||||
{"id":3,
|
||||
"dishlink":"?=dish3",
|
||||
"dishname":"Блюдо3"
|
||||
},
|
||||
{"id":4,
|
||||
"dishlink":"?=dish4",
|
||||
"dishname":"Блюдо4"
|
||||
},
|
||||
{"id":5,
|
||||
"dishlink":"?=dish5",
|
||||
"dishname":"Блюдо5"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
const EDATEAM_JWT_TOKEN = 'secretyk token';
|
||||
|
||||
module.exports = {EDATEAM_JWT_TOKEN};
|
||||
@@ -0,0 +1,51 @@
|
||||
const { getListRecipes , getRecipe, addFavorite , getFavorites} = require('./controllers');
|
||||
|
||||
const router = require('express').Router();
|
||||
|
||||
router.get('/recipes', async (req, res) => {
|
||||
try {
|
||||
const result = await getListRecipes();
|
||||
return res.status(200).json({ success: true, data: result });
|
||||
} catch (error) {
|
||||
console.error('Error in GET /recipes:', error.message);
|
||||
return res.status(500).json({ success: false, message: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
router.post('/recipe', async(req,res)=>{
|
||||
try{
|
||||
const result = await getRecipe(req.body);
|
||||
|
||||
return res.status(200).json({success:true, data: result});
|
||||
}
|
||||
catch(error){
|
||||
console.error('Error in GET /recipes:', error.message);
|
||||
return res.status(500).json({ success: false, message: error.message });
|
||||
}
|
||||
})
|
||||
|
||||
router.post('/favorites', async (req, res) => {
|
||||
try {
|
||||
|
||||
const { userId, recipeId } = req.body;
|
||||
const result = await addFavorite(userId, recipeId);
|
||||
return res.status(200).json({ success: true, data: result });
|
||||
} catch (error) {
|
||||
console.error('Error in POST /favorites:', error.message);
|
||||
return res.status(500).json({ success: false, message: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
router.post('/get-favorites', async(req,res) =>{
|
||||
try {
|
||||
const { userId } = req.body;
|
||||
const result = await getFavorites(userId);
|
||||
console.log(result)
|
||||
return res.status(200).json({ success: true, data: result });
|
||||
} catch (error) {
|
||||
console.error('Error in POST /get-favorites:', error.message);
|
||||
return res.status(500).json({ success: false, message: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,35 @@
|
||||
const { requiredFields , getFavorites, addRecipe} = require('./controllers');
|
||||
|
||||
const router = require('express').Router();
|
||||
|
||||
router.post('/favorites', requiredFields('id'), async(req,res)=>{
|
||||
try{
|
||||
const recipes = await getFavorites(req.body);
|
||||
res.status(200).send(getResponse(recipes));
|
||||
}
|
||||
catch(error){
|
||||
res.status(400).send(getResponse(error.message));
|
||||
}
|
||||
})
|
||||
|
||||
router.post('/add-recept', async (req, res) => {
|
||||
let error = null;
|
||||
let result = null;
|
||||
|
||||
try {
|
||||
result = await addRecipe(req.body);
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
console.error(`Error in POST /add-recept: ${error}`);
|
||||
}
|
||||
|
||||
return res.status(error ? 500 : 201).json({
|
||||
message: error ? error : 'Recipe added successfully',
|
||||
id: result?.id
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 1426 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user