- GitFit allows you to log your workout types, check your monthly personal records, create personal workout goals, and join public workout challenges all in one beautiful site.
Technology and Frameworks Used:
Project Contributors:
Project tutorial:
- Register to the site
- Login
- Add a workout
- Create new public or private challenge
- Join already created public challenges
- Our team was challenged with creating a fullstack project that showcases our newfound backend skills as well as our front-end knowledge.
- Front-end Req:
- The app needed to implement responsive web design techniques.
- The goal of this project was mostly centered around the backend development...that being said, we still wanted our users to have a great visual experience using GitFit.
- We were allowed to use our preference of front-end frameworks.
- Backend Req:
- To use Express for the HTTP framework
- Use a view engine for our templating
- Use PostgreSQL for our Database
- Must have atleast three tables.
- Where two of the tables are related (i.e. foreign keys)
- Must have atleast three tables.
- The power of Sequelize
- Specifically when we had a many to many relationship for our challenges to users table.
- Once we got the migrations and models set up properly (specifically using the belongsToMany), Sequelize has a multitude of built in methods that we were able to use to quickly accomplish the tasks necessary.
db.User.findOne({
where: {
id: req.session.user.id
}
})
.then(user=>{
user.getChallenges({
where: {
is_completed: false,
}
})
.then(challenges => {
if(challenges.length === 0){
res.status(404).json({error: `No ${workoutType.toLowerCase()} challenges found`})
}else{
res.status(200).json(challenges);
}
})
.catch(e=>{
console.log(e);
})
})
.catch(e=>{
console.log(e);
})
- Above demonstrates one of these powerful methods that sequelize allows us to access. Once we find the right user by referecing the session user id, we can then call the getChallenges sequelize on the user result.
- Below is a list of other methods we could also access using the same logic from above:
- user.getChallenges()
- user.countChallenges()
- user.hasChallenge()
- user.hasChallenges()
- user.setChallenges()
- user.addChallenge()
- user.addChallenges()
- user.removeChallenge()
- user.removeChallenges()
- user.createChallenge()
- Below is a list of other methods we could also access using the same logic from above: