Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,12 @@ PORT=

//* https://developer.edamam.com/

nutrition_API_app_id=
NUTRITION_API_APP_ID=


nutrition_API_app_key=


//*


recipe_API_app_id=


recipe_API_app_key=
NUTRITION_API_APP_KEY=


MONGO_URL=

DB_NAME=
APP_KEY=
39 changes: 39 additions & 0 deletions controllers/DietPlane.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';
const { request, response } = require('express');
const dietModel = require('../models/DietPlan.model');


const getDiteInfo = (request, response) => {
try {
dietModel.find({ email: request.query.email }, (error, DietData) => {
if (error) {
response.send(error);
}
response.json(DietData)
});
} catch (error) {
response.send(error);
}
};

const AddInfo = (request, response) => {

const { gender, height, weight, age, activety, email } = request.body;
const newUser = new dietModel({
gender, height, weight, age, activety, email
})
newUser.save();
response.json(newUser);

};
const UpdateInfo = (request, response) => {

const { gender, height, weight, age, activety, email } = request.body;
const userId=request.params.user_id;
dietModel.findByIdAndUpdate({_id:userId},{ gender, height, weight, age, activety, email },{new:true} ,(error,updatedUserData)=>{
response.json(updatedUserData)
});
}


module.exports = { getDiteInfo, AddInfo, UpdateInfo }
23 changes: 23 additions & 0 deletions controllers/news.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';
const app_key=process.env.APP_KEY;
const axios=require('axios')


const getNews=async(request,respond)=>{
const item=request.query.qintitle;
console.log(item)

const UrlForItem="https://newsdata.io/api/1/news"

const getItem=await axios.get(`${UrlForItem}?apikey=${app_key}&qintitle=${item}&language=en`)




respond.json(getItem.data)
console.log(getItem.data)


}

module.exports=getNews
21 changes: 21 additions & 0 deletions controllers/tracker.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const app_id = process.env.NUTRITION_API_APP_ID;
const app_key = process.env.NUTRITION_API_APP_KEY;
const axios = require('axios')


const getTracker = async (request, respond) => {
const item = request.query.ingr;
console.log(item)

const UrlForItem = "https://api.edamam.com/api/nutrition-data"

const getItem = await axios.get(`${UrlForItem}?app_id=${app_id}&app_key=${app_key}&nutrition-type=logging&ingr=${item}`)

respond.json(getItem.data)


}

module.exports = getTracker
34 changes: 34 additions & 0 deletions helpers/DirtPlan.seed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';

const dietModel = require('../models/DietPlan.model');

const seedBook = () => {


const firstUser = new dietModel({
gender: 'female',
height: '170',
weight: '59',
age: '25',
activety: '1.14',
email: 'salsabilmislat196@gmail.com',

});
firstUser.save();

const secondtUser = new dietModel({
gender: 'male',
height: '170',
weight: '80',
age: '31',
activety: '1.14',
email: 'ahmadhamzh@ymail.com',

});
secondtUser.save();
console.log("Data seeded!");
}



module.exports = seedBook;
17 changes: 17 additions & 0 deletions models/DietPlan.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';
const mongoose = require('mongoose');

const dietPlanSchema = new mongoose.Schema({

gender: { type: String },
height: { type: String },
weight: { type: String },
age: { type: String },
activety: { type: String },
email: { type: String },
// recipe: { any: [{}] }

})
const dietModel = mongoose.model('ourinfo', dietPlanSchema);

module.exports = dietModel;
Loading