├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_report.md ├── Pull_Request_Template.md └── workflows │ ├── auto-comment-on-issue.yml │ └── build.yml ├── .gitignore ├── .hintrc ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── index.html ├── package-lock.json ├── package.json ├── public ├── 157257.ico ├── Screenshot 2023-06-17 061947.jpg ├── image.png ├── manifest.json └── robots.txt ├── server ├── .gitignore ├── controllers │ ├── admin-controller.js │ ├── auth-controller.js │ ├── blogs-controller.js │ ├── plan-controller.js │ └── user-controller.js ├── index.js ├── middleware │ ├── adminMiddleware.js │ └── authMiddleware.js ├── models │ ├── admin-model.js │ ├── blog-model.js │ ├── plan-model.js │ └── user-model.js ├── package-lock.json ├── package.json ├── routes │ ├── admin-route.js │ ├── auth-route.js │ ├── blog-route.js │ ├── plan-route.js │ ├── user-route.js │ └── welcomeRoute.js └── validation │ ├── validation.schema.js │ └── zodschema.js ├── src ├── App.css ├── App.jsx ├── assets │ ├── JSON │ │ └── contactus.json │ ├── img │ │ ├── Circle Loader.gif │ │ ├── avatar01.png │ │ ├── avatar02.png │ │ ├── avatar03.png │ │ ├── avatar04.png │ │ ├── dumble.png │ │ ├── extended.png │ │ ├── gym-02.png │ │ ├── lunges.png │ │ ├── supdated_avatar03.png │ │ ├── testinomial01.jpeg │ │ ├── testinomial02.jpg │ │ ├── testinomial03.jpg │ │ ├── testinomial04.jpg │ │ ├── testinomial05.jpg │ │ ├── trainer-png.png │ │ ├── trainer.png │ │ ├── updated_avatar01.png │ │ ├── updated_avatar03.jpg │ │ └── yoga-pose.png │ └── repo imges │ │ ├── Screenshot 1.jpg │ │ └── Screenshot 2.jpg ├── components │ ├── Header │ │ └── Header.jsx │ └── UI │ │ ├── About.jsx │ │ ├── BackToTop.jsx │ │ ├── Classes.jsx │ │ ├── ContactUs.jsx │ │ ├── Diet.jsx │ │ ├── Error.jsx │ │ ├── Exercises.jsx │ │ ├── Footer.jsx │ │ ├── Hero.jsx │ │ ├── Licensing.jsx │ │ ├── Login.jsx │ │ ├── Pricing.jsx │ │ ├── Register.jsx │ │ ├── Reviews.jsx │ │ ├── Start.jsx │ │ ├── Testimonials.jsx │ │ ├── privacypolicy.jsx │ │ └── termsandconditions.jsx ├── index.jsx └── styles │ ├── About.css │ ├── BackToTop.css │ ├── Classes.css │ ├── Diet.css │ ├── PrivacyPolicy.css │ ├── Reviews.css │ ├── contactUs.css │ ├── error.css │ ├── exercises.css │ ├── footer.css │ ├── header.css │ ├── hero.css │ ├── licensing.css │ ├── pricing.css │ ├── register.css │ ├── start.css │ ├── termsandconditions.css │ └── testimonials.css └── vite.config.js /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | 22 | What problem is this feature trying to solve? 23 | 24 | How do we know when the feature is complete? 25 | -------------------------------------------------------------------------------- /.github/Pull_Request_Template.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. 4 | 5 | Fixes: #(issue no.) 6 | 7 | 8 | 9 | ## Type of change 10 | 11 | 12 | 13 | - [ ] Bug fix (non-breaking change which fixes an issue) 14 | - [ ] New feature (non-breaking change which adds functionality) 15 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 16 | - [ ] This change requires a documentation update 17 | 18 | # Checklist: 19 | 20 | 21 | - [ ] I have made this from my own 22 | - [ ] I have taken help from some online resourses 23 | - [ ] My code follows the style guidelines of this project 24 | - [ ] I have performed a self-review of my own code 25 | - [ ] I have commented my code, particularly in hard-to-understand areas 26 | - [ ] I have made corresponding changes to the documentation 27 | - [ ] My changes generate no new warnings 28 | 29 | 30 | # ATTACH SCREEN-SHOTS / DEPLOYMENT LINK 31 | -------------------------------------------------------------------------------- /.github/workflows/auto-comment-on-issue.yml: -------------------------------------------------------------------------------- 1 | name: Auto Comment on Issue 2 | 3 | on: 4 | issues: 5 | types: [opened] 6 | 7 | permissions: 8 | issues: write 9 | 10 | jobs: 11 | comment: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Add Comment to Issue 16 | run: | 17 | COMMENT=$(cat < 18 | npm install 19 | ``` 20 | 21 | 4. Create a new branch for your contribution: 22 | 23 | ```bash 24 | git checkout -b feature/your-feature-name 25 | ``` 26 | 27 | 5. Make your changes and commit them with clear and concise commit messages: 28 | 29 | ```bash 30 | git commit -m "Add feature/fix: description of your changes" 31 | ``` 32 | 33 | 6. Push your changes to your fork: 34 | 35 | ```bash 36 | git push origin feature/your-feature-name 37 | ``` 38 | 39 | 7. Create a pull request (PR) to the `main` branch of the original repository. 40 | 41 | ## Guidelines for Contributions 42 | 43 | - Please ensure that your code adheres to the project's coding standards and style. 44 | - Write clear and concise code with meaningful comments when necessary. 45 | - Document any new functionality or changes you introduce. 46 | - Test your changes thoroughly before submitting a PR to ensure they do not introduce bugs. 47 | 48 | ## Reporting Bugs 49 | 50 | If you encounter a bug in the project, please follow these steps to report it: 51 | 52 | 1. Check if the bug has already been reported in the [Issues](https://github.com/your-username/FitBody.git) section of the repository. If it hasn't, create a new issue. 53 | 2. Provide a clear and detailed description of the bug, including steps to reproduce it. 54 | 3. Include any relevant error messages or stack traces. 55 | 4. If possible, provide a fix or suggest a solution to the issue. 56 | 57 | ## Feature Requests 58 | 59 | If you have an idea for a new feature or improvement, please follow these steps: 60 | 61 | 1. Check if the feature or improvement has already been requested in the [Issues](https://github.com/your-username/FitBody/issues) section of the repository. If it hasn't, create a new issue. 62 | 2. Describe the new feature or improvement in detail, including why it's needed and how it should work. 63 | 64 | ## Code Review Process 65 | 66 | All contributions will be reviewed by project maintainers. Please be patient and be prepared to make changes to your code based on their feedback. 67 | 68 | ## Code of Conduct 69 | 70 | Participating in this project, you agree to abide by the [Code of Conduct](CODE_OF_CONDUCT.md). Please report any unacceptable behavior to rajpootabhay423@gmail.com 71 | ## Thank You 72 | 73 | We appreciate your contributions to the Fitbody project. Your help makes a difference in Fitness of Peoples. Thank you for being a part of this community! 74 | 75 | --- 76 | 77 | Feel free to customize the above template to match your project's specific needs and requirements. 78 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Abhay Rajpoot 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |

🏋🏽FitBody🏋🏽

3 |

4 |

5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 |
24 |

25 | 26 | # 27 | 28 | 29 | 30 | 31 | ## 📍Table Of Contents 32 | 33 | - [About](#About) 34 | - [Live Demo](#LiveDemo) 35 | - [Issues to be welcomed](#Issuestobewelcomed) 36 | - [Building FitBody](#BuildingFitBody) 37 | - [Note](#NOTE) 38 | - [Features](#Features) 39 | - [Technology Stack](#TechnologyStack) 40 | - [License](#License) 41 | - [Repo Status](#RepoStatus) 42 | - [Our Contributors](#OurContributors) 43 | 44 | 45 | ## 🎯About 46 | FitBody is the growing platform for Gym-enthusiasts and they can choose there respective domains for the pricing category and we are happy to invite you in the gym-community. 47 | 48 | ## 🖱️Live Demo 49 | 50 | Here is the live view of this website. It is hosted on Vercel https://fit-body-delta.vercel.app/ 51 | 52 | ### How to Contribute to this repository 53 | 54 | 1. Fork the repository (Click the Fork button in the top right of this page, 55 | click your Profile Image) 56 | 57 | 2. Clone the forked repository to your local machine. 58 | 59 | 3. Make your branch from test branch. 60 | 61 | ```markdown 62 | git clone https://github.com/abhay-raj19/FitBody.git 63 | ``` 64 | 65 | 3. change the present working directory to 66 | 67 | ```markdown 68 | cd FitBody 69 | ``` 70 | 71 | 5. Make your changes 72 | 73 | ```markdown 74 | git add . 75 | ``` 76 | ```markdown 77 | git commit -m "Your commit Message" 78 | ``` 79 | ```markdown 80 | git push origin branch-name 81 | 82 | ``` 83 | 84 | 6. Make a pull request. 85 | 7. Do ⭐ the repository. 86 | 87 | ### 🔩Issues to be welcomed 88 | 89 | 1. Content Correction. 90 | 2. Back pages for the linking the webpages. 91 | 3. Navigation of the pages. 92 | 4. New cards for Testimonials with Images. 93 | 94 | ### 📦️Building FitBody 95 | 96 | 1. Install npm from browser(windows), using ``sudo apt install npm``(linux) in the terminal. 97 | 98 | 2. In the root directory: `npm install` for downloading all the dependencies needed for the project. 99 | 100 | 3. Run `npm start` for starting the server (FitBody is currently running on `localhost:3000`) 101 | 102 | 103 | 104 | Happy coding :) 105 | 106 | 107 | ### 🗒️NOTE 108 | 109 | - Make Sure you commit your changes in a new branch. 110 | - Make Sure you Give a proper name to your files describing the addition. 111 | - Also Make Sure you comment on your code wherever necessary. 112 | 113 | ## 💫Features 114 | - Personalized Workout Plans: Provide the option for users to receive personalized workout plans tailored to their fitness goals. Users can input their preferences and goals, and the website generates a customized plan for them. 115 | 116 | - Progress Tracking: Enable users to track their fitness progress over time. They can input their measurements, record workout sessions, and monitor their improvements through charts or graphs. 117 | 118 | - Nutrition Guidance: Offer nutrition tips and guidance to help users maintain a healthy diet and complement their fitness routines. This can include articles, meal plans, and recipes. 119 | 120 | - Community and Social Interaction: Foster a sense of community among gym members through features like forums or social media integration. Users can connect, share their fitness journeys, and support one another. 121 | 122 | - Blog and Articles: Publish informative articles and blog posts related to fitness, health, and wellness. 123 | 124 | ## 💻Technology Stack 125 | 126 | ![JAVASCRIPT](https://img.shields.io/badge/JavaScript-F7DF1E?style=for-the-badge&logo=javascript&logoColor=black) 127 | ![CSS5](https://img.shields.io/badge/CSS3-1572B6?style=for-the-badge&logo=css3&logoColor=white) 128 | ![HTML5](https://img.shields.io/badge/HTML5-E34F26?style=for-the-badge&logo=html5&logoColor=white) 129 | ![MongoDB](https://img.shields.io/badge/MongoDB-%234ea94b.svg?style=for-the-badge&logo=mongodb&logoColor=white) 130 | ![NodeJS](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white) 131 | 132 | ## License 133 | Licensed under the MIT License. 134 | ## Repo Status 135 | 136 | ![GitHub PR Open](https://img.shields.io/github/issues-pr/abhay-raj19/FitBody?style=for-the-badge&color=aqua) 137 | ![GitHub PR closed](https://img.shields.io/github/issues-pr-closed-raw/abhay-raj19/FitBody?style=for-the-badge&color=blue) 138 | ![GitHub language count](https://img.shields.io/github/languages/count/abhay-raj19/FitBody?style=for-the-badge&color=brightgreen) 139 |

140 | 141 | ## Join our Discord Community 142 | To get latest updates on the project and to interact with the community. We are happy to help you with your queries. 143 | 144 | [![Join our Discord server!](https://invidget.switchblade.xyz/9jqmCs3KX3?theme=light)](https://discord.gg/Ra8vsr5bPK) 145 | 146 | 147 | 148 | ## 🤝Our Contributors 149 | 150 | 151 | 152 | 153 | 154 | 155 | Thank you to all the amazing contributors who have made this project possible! 156 | 157 | 158 | Show some ❤️ by starring this repository ! 159 | 160 |

()

161 | 162 | 163 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 33 | FitBody 34 | 47 | 48 | 49 |
50 | 51 |
52 | 53 | 54 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gym-website", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@emotion/react": "^11.11.4", 7 | "@emotion/styled": "^11.11.5", 8 | "@gsap/react": "^2.1.1", 9 | "@mui/icons-material": "^5.15.17", 10 | "@mui/material": "^5.15.17", 11 | "@testing-library/jest-dom": "^5.16.5", 12 | "@testing-library/react": "^13.4.0", 13 | "@testing-library/user-event": "^13.5.0", 14 | "aos": "^3.0.0-beta.6", 15 | "font-awesome": "^4.7.0", 16 | "gsap": "^3.12.5", 17 | "locomotive-scroll": "^5.0.0-beta.12", 18 | "lottie-react": "^2.4.0", 19 | "react": "^18.2.0", 20 | "react-dom": "^18.2.0", 21 | "react-hot-toast": "^2.4.1", 22 | "react-router-dom": "^6.23.1", 23 | "remixicon": "^2.5.0", 24 | "styled-components": "^5.3.11", 25 | "swiper": "^9.3.2", 26 | "web-vitals": "^2.1.4" 27 | }, 28 | "scripts": { 29 | "start": "vite", 30 | "build": "vite build", 31 | "preview": "vite preview", 32 | "dev": "vite" 33 | }, 34 | "eslintConfig": { 35 | "extends": [ 36 | "react-app", 37 | "react-app/jest" 38 | ] 39 | }, 40 | "browserslist": { 41 | "production": [ 42 | ">0.2%", 43 | "not dead", 44 | "not op_mini all" 45 | ], 46 | "development": [ 47 | "last 1 chrome version", 48 | "last 1 firefox version", 49 | "last 1 safari version" 50 | ] 51 | }, 52 | "devDependencies": { 53 | "@emotion/babel-plugin": "^11.11.0", 54 | "@vitejs/plugin-react": "^4.2.1", 55 | "esbuild": "^0.15.0", 56 | "vite": "^5.2.11" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /public/157257.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhay-raj19/FitBody/dd9cc76f2757345c523bcc0768e638b6a38937c0/public/157257.ico -------------------------------------------------------------------------------- /public/Screenshot 2023-06-17 061947.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhay-raj19/FitBody/dd9cc76f2757345c523bcc0768e638b6a38937c0/public/Screenshot 2023-06-17 061947.jpg -------------------------------------------------------------------------------- /public/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhay-raj19/FitBody/dd9cc76f2757345c523bcc0768e638b6a38937c0/public/image.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /server/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | .env 6 | -------------------------------------------------------------------------------- /server/controllers/admin-controller.js: -------------------------------------------------------------------------------- 1 | import Admin from '../models/admin-model.js' 2 | import jwt from 'jsonwebtoken' 3 | import bcrypt from 'bcryptjs' 4 | import User from '../models/user-model.js'; 5 | 6 | export const registerAdmin = async (req, res) => { 7 | 8 | try { 9 | const { name, email, contact, password, confirmPassword } = req.body; 10 | 11 | if (!name || !email || !contact || !password || !confirmPassword) { 12 | return res.status(400).json({ message: "Please Enter all the Feilds", success: false }); 13 | } 14 | 15 | if (password !== confirmPassword) { 16 | return res.status(400).json({ message: "Confirm password do not match.", success: false }); 17 | } 18 | 19 | const adminExists = await Admin.findOne({ email }); 20 | const userExists=await User.findOne({email}) 21 | 22 | 23 | if (adminExists || userExists) { 24 | return res.status(400).json({ message: "account already exists", success: false }); 25 | } 26 | 27 | const hash_pass = await bcrypt.hash(password, 10) 28 | const admin = await Admin.create({ 29 | name, 30 | email, 31 | password: hash_pass, 32 | contact, 33 | }); 34 | 35 | 36 | if (admin) { 37 | return res.status(201).json({ message: "Account created successfully.", success: true }); 38 | } 39 | else { 40 | return res.status(500).json({ message: "internal server error", success: false }); 41 | } 42 | } 43 | catch (err) { 44 | return res.status(500).json({ message: "internal server error", success: false, err }); 45 | } 46 | } 47 | 48 | export const adminLogin = async (req, res) => { 49 | 50 | try { 51 | const { email, password } = req.body; 52 | const admin = await Admin.findOne({ email }); 53 | 54 | if (!admin) { 55 | return res.status(400).json({ message: "Invalid email or password.", success: false }) 56 | } 57 | const isMatch = await bcrypt.compare(password, admin.password) 58 | if (!isMatch) { 59 | return res.status(400).json({ message: "Invalid email or password.", success: false }) 60 | } 61 | 62 | const tokenData={ 63 | adminId:admin._id 64 | } 65 | const token = await jwt.sign(tokenData, process.env.JWT_SECRET_KEY, { expiresIn: '1d' }); 66 | if (!token) { 67 | return res.status(500).json({ message: "internal server error", success: false }) 68 | } 69 | return res.status(200).json({ 70 | token: token, 71 | message: "Logged in successful", 72 | success: true 73 | }); 74 | } 75 | catch (err) { 76 | return res.status(500).json({ message: "internal server error", success: false, err }); 77 | } 78 | }; 79 | 80 | export const changePassword = async (req, res) => { 81 | try { 82 | const { email, current_password, new_password } = req.body; 83 | const admin = await Admin.findOne({ email }) 84 | if (!admin) { 85 | return res.status(400).json({ message: "No user found!", success: false }); 86 | } 87 | const isPasswordMatch = await bcrypt.compare(current_password, admin.password); 88 | if (!isPasswordMatch) 89 | return res.status(400).json({ 90 | message: "Current password is incorrect.", 91 | success: false 92 | }) 93 | admin.password = new_password 94 | await admin.save() 95 | return res.status(200).json({ message: "password changed successfully.", success: true }) 96 | } 97 | catch (err) { 98 | return res.status(500).json({ message: "internal server error", err, success: false }) 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /server/controllers/auth-controller.js: -------------------------------------------------------------------------------- 1 | import User from '../models/user-model.js' 2 | import jwt from 'jsonwebtoken' 3 | import bcrypt from 'bcryptjs' 4 | import Admin from '../models/admin-model.js'; 5 | 6 | export const registerUser = async (req, res) => { 7 | 8 | try { 9 | const { name, age, email, contact, password, confirmPasssword, panNumber } = req.body; 10 | 11 | if (!name || !email || !age || !contact || !password || !confirmPasssword || !panNumber) { 12 | return res.status(400).json({ message: "Please Enter all the Feilds", success: false }); 13 | } 14 | 15 | if (password !== confirmPasssword) { 16 | return res.status(400).json({ message: "Confirm password do not match.", success: false }); 17 | } 18 | 19 | const userExists = await User.findOne({ email }); 20 | const adminExists=await Admin.findOne({email}) 21 | if (userExists || adminExists) { 22 | return res.status(400).json({ message: "account already exists", success: false }); 23 | } 24 | 25 | const user = await User.create({ 26 | name, 27 | email, 28 | password, 29 | age, 30 | contact, 31 | panNumber 32 | }); 33 | 34 | 35 | if (user) { 36 | return res.status(201).json({ message: "Account created successfully.", success: true }); 37 | } 38 | else { 39 | return res.status(500).json({ message: "internal server error", success: false }); 40 | } 41 | } 42 | catch (err) { 43 | return res.status(500).json({ message: "internal server error", success: false, err }); 44 | } 45 | } 46 | 47 | export const authUser = async (req, res) => { 48 | 49 | try { 50 | const { email, password } = req.body; 51 | const user = await User.findOne({ email }); 52 | if (user && (await user.matchPassword(password))) { 53 | 54 | const tokenData = { 55 | userId: user._id 56 | }; 57 | 58 | const token = await jwt.sign(tokenData, process.env.JWT_SECRET_KEY, { expiresIn: '1d' }); 59 | if (!token) { 60 | return res.status(500).json({ message: "internal server error", success: false }) 61 | } 62 | return res.status(200).json({ 63 | token: token, 64 | message: "Logged in successful", 65 | success: true 66 | }); 67 | } 68 | else { 69 | return res.status(401).json({ message: "Invalid Email or Password", success: false }); 70 | } 71 | } 72 | catch (err) { 73 | return res.status(500).json({ message: "internal server error", success: false, err }); 74 | } 75 | }; 76 | 77 | export const changePassword = async (req, res) => { 78 | try { 79 | const { email, current_password, new_password } = req.body; 80 | const user = await User.findOne({ email }) 81 | if (!user) { 82 | return res.status(400).json({ message: "No user found!", success: false }); 83 | } 84 | const isPasswordMatch = await bcrypt.compare(current_password, user.password); 85 | if (!isPasswordMatch) 86 | return res.status(400).json({ 87 | message: "Current password is incorrect.", 88 | success: false 89 | }) 90 | user.password = new_password 91 | await user.save() 92 | return res.status(200).json({ message: "password changed successfully.", success: true }) 93 | } 94 | catch (err) { 95 | return res.status(500).json({ message: "internal server error", err, success: false }) 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /server/controllers/blogs-controller.js: -------------------------------------------------------------------------------- 1 | import Blog from "../models/blog-model.js"; 2 | import User from "../models/user-model.js"; 3 | import mongoose from "mongoose"; 4 | export const addBlog = async (req, res) => { 5 | try { 6 | const userID = req.id; 7 | const { title, description, category } = req.body; 8 | if (!title || !description || !category) { 9 | return res.status(400).json({ message: "Please Enter all the Feilds", success: false }); 10 | } 11 | const user = await User.findById(userID) 12 | const blog = new Blog({ 13 | title, 14 | description, 15 | author:userID, 16 | category 17 | }) 18 | 19 | const session = await mongoose.startSession() 20 | session.startTransaction() 21 | 22 | 23 | if (!blog || !user) { 24 | return res.status(500).json({ message: "internal server error", err, success: false }) 25 | } 26 | 27 | user.blogs.push(blog._id) 28 | await user.save({ session }) 29 | await blog.save({ session }) 30 | await session.commitTransaction() 31 | 32 | return res.status(200).json({message:'blog created sucessfully.',success:true,blog}) 33 | } 34 | catch (err) { 35 | return res.status(500).json({ message: "internal server error", err, success: false }) 36 | } 37 | } 38 | 39 | export const deleteBlog = async (req, res) => { 40 | try { 41 | const { id } = req.params; 42 | 43 | let blog = await Blog.findByIdAndDelete(id).populate("author"); 44 | 45 | if (!blog) { 46 | return res.status(404).json({ message: 'Blog not found.', success: false }); 47 | } 48 | 49 | if (blog.author) { 50 | await blog.author.blogs.pull(blog._id); 51 | await blog.author.save(); 52 | } 53 | 54 | return res.status(200).json({ message: 'Blog deleted successfully.', success: true }); 55 | } catch (err) { 56 | return res.status(500).json({ message: "Internal server error", err, success: false }); 57 | } 58 | } 59 | 60 | export const showAllBlogs = async (req, res) => { 61 | try { 62 | const blogs = await Blog.find().populate({ 63 | path: 'author', 64 | select: 'name' 65 | }) 66 | if (!blogs) { 67 | return res.status(500).json({ message: 'internal server error.', success: false }) 68 | } 69 | return res.status(200).send({ 70 | success: true, 71 | BlogCount: blogs.length, 72 | message: "All blogs list", 73 | blogs 74 | }) 75 | } 76 | catch (err) { 77 | return res.status(500).json({ message: "Internal server error", err, success: false }); 78 | } 79 | } 80 | 81 | export const getBlog=async(req,res)=>{ 82 | try{ 83 | const {id}=req.params; 84 | const blog = await Blog.findById(id).populate({ 85 | path: 'author', 86 | select: 'name' 87 | }) 88 | if (!blog) { 89 | return res.status(404).send({ 90 | success: false, 91 | message: "blog not found with this ID", 92 | }) 93 | } 94 | return res.status(200).send({ 95 | success: true, 96 | message: "blog fetched successfully!", 97 | blog 98 | }) 99 | } 100 | catch(err) 101 | { 102 | return res.status(500).json({ message: "Internal server error", err, success: false }); 103 | } 104 | } 105 | 106 | export const getUserBlogs=async(req,res)=>{ 107 | try{ 108 | const userID=req.id; 109 | const userBlogs=await User.findById(userID).populate('blogs') 110 | if(!userBlogs) 111 | { 112 | return res.status(500).json({ message: 'internal server error.', success: false }) 113 | } 114 | const {blogs}=userBlogs 115 | return res.status(200).json({ 116 | success: true, 117 | BlogCount: blogs.length, 118 | message: "All blogs list", 119 | blogs 120 | }) 121 | } 122 | catch(err) 123 | { 124 | return res.status(500).json({ message: "Internal server error", err, success: false }); 125 | } 126 | } 127 | 128 | export const updateBlog = async (req, res) => { 129 | try { 130 | const { id } = req.params; 131 | const updateData = req.body; 132 | 133 | if (!updateData || Object.keys(updateData).length === 0) { 134 | return res.status(400).json({ message: "Update data is required.", success: false }); 135 | } 136 | 137 | const updatedBlog = await Blog.findByIdAndUpdate(id, updateData, { new: true }); 138 | 139 | if (!updatedBlog) { 140 | return res.status(404).json({ message: "Blog not found.", success: false }); 141 | } 142 | 143 | return res.status(200).json({ message: "Blog updated successfully.", success: true, updatedBlog }); 144 | 145 | } catch (err) { 146 | return res.status(500).json({ message: "Internal server error", err, success: false }); 147 | } 148 | } 149 | 150 | export const getBlogsByCategory=async(req,res)=>{ 151 | try{ 152 | let {category}=req.params 153 | category=decodeURIComponent(category) 154 | 155 | const blogs = await Blog.find({ category }); 156 | if(!blogs) 157 | { 158 | return res.status(404).json({ message: "No blogs found.", success: false }); 159 | } 160 | return res.status(200).json({ 161 | success: true, 162 | BlogCount: blogs.length, 163 | message: `Blogs of category ${category}`, 164 | blogs 165 | }) 166 | } 167 | catch(err) 168 | { 169 | return res.status(500).json({ message: "Internal server error", err, success: false }); 170 | } 171 | } -------------------------------------------------------------------------------- /server/controllers/plan-controller.js: -------------------------------------------------------------------------------- 1 | import Plan from "../models/plan-model.js" 2 | 3 | 4 | export const addPlan = async (req, res) => { 5 | try { 6 | const { name, description, duration, price } = req.body 7 | if (!name || !description || !duration || !price) { 8 | return res.status(400).json({ message: "please enter all the fields.", success: false }) 9 | } 10 | const plan = await Plan.create({ 11 | name, 12 | description, 13 | duration, 14 | price 15 | }) 16 | if (!plan) { 17 | return res.status(500).json({ message: "internal server error", success: false }) 18 | } 19 | return res.status(201).json({ message: "plan added successfully.", success: true }) 20 | } 21 | catch (err) { 22 | return res.status(500).json({ message: "internal server error", success: false, err }) 23 | } 24 | } 25 | 26 | export const getAllPlans = async (req, res) => { 27 | try { 28 | const plans = await Plan.find() 29 | if (!plans) 30 | { 31 | return res.status(500).json({message:"internal server error",success:false}) 32 | } 33 | return res.status(200).json({plans,success:true,}) 34 | } 35 | catch (err) { 36 | return res.status(500).json({ message: "internal server error", success: false, err }) 37 | } 38 | } 39 | 40 | export const getPlanDetails=async(req,res)=>{ 41 | try{ 42 | const {id}=req.params 43 | const plan=await Plan.findById(id).select("-password") 44 | if(!plan) 45 | { 46 | return res.status(500).json({ message: "internal server error", err, success: false }) 47 | } 48 | return res.status(200).json({ plan_details:plan,success: true }) 49 | } 50 | catch(err) 51 | { 52 | return res.status(500).json({ message: "internal server error", success: false, err }) 53 | } 54 | } 55 | 56 | export const deletePlan=async(req,res)=>{ 57 | try{ 58 | const {id}=req.params; 59 | const plan=await Plan.findByIdAndDelete(id) 60 | if(!plan) 61 | { 62 | return res.status(500).json({ message: "internal server error", err, success: false }) 63 | } 64 | return res.status(200).json({ message:"plan deleted successfully.",success: true }) 65 | } 66 | catch(err) 67 | { 68 | return res.status(500).json({ message: "internal server error", success: false, err }) 69 | } 70 | } 71 | 72 | export const getPlanUsers=async(req,res)=>{ 73 | try 74 | { 75 | const {id}=req.params; 76 | const plan = await Plan.findById(id).populate('users'); 77 | if (!plan) { 78 | return res.status(404).json({ message: "Plan not found." }); 79 | } 80 | const users=plan.users 81 | return res.status(200).json({users}) 82 | } 83 | catch(err) 84 | { 85 | return res.status(500).json({ message: "internal server error", success: false, err }) 86 | } 87 | } 88 | 89 | -------------------------------------------------------------------------------- /server/controllers/user-controller.js: -------------------------------------------------------------------------------- 1 | import Plan from '../models/plan-model.js'; 2 | import User from '../models/user-model.js'; 3 | 4 | export const userDetails = async (req, res) => { 5 | const userID = req.params.id; 6 | try { 7 | const user = await Student.findById(userID).select('-password') 8 | if (!user) { 9 | return res.status(500).json({ message: "internal server error", err, success: false }) 10 | } 11 | return res.status(200).json({ userDetails: user, success: true }) 12 | } 13 | catch (err) { 14 | return res.status(500).json({ message: "internal server error", err, success: false }) 15 | } 16 | } 17 | 18 | export const getAllUsers = async (req, res) => { 19 | try { 20 | const user = await User.find() 21 | if (!user) { 22 | return res.status(500).json({ message: "internal server error", err, success: false }) 23 | } 24 | return res.status(200).json({ user }) 25 | } 26 | catch (err) { 27 | return res.status(500).json({ message: "internal server error", err, success: false }) 28 | } 29 | } 30 | 31 | 32 | 33 | export const addUserToPlan = async (req, res) => { 34 | const planID = req.params.id; 35 | const userID = req.id; 36 | 37 | try { 38 | const user = await User.findById(userID); 39 | const plan = await Plan.findById(planID); 40 | 41 | if (!user || !plan) { 42 | return res.status(404).json({ message: "user or plan not found." }); 43 | } 44 | 45 | const startDate = new Date(); 46 | const endDate = new Date(); 47 | endDate.setMonth(startDate.getMonth() + plan.duration); 48 | 49 | // Formatting start date 50 | const formattedStartDate = `${startDate.getDate()}/${startDate.getMonth() + 1}/${startDate.getFullYear()}`; 51 | 52 | // Formatting end date 53 | const formattedEndDate = `${endDate.getDate()}/${endDate.getMonth() + 1}/${endDate.getFullYear()}`; 54 | 55 | user.planStartDate= formattedStartDate; 56 | user.planEndDate= formattedEndDate; 57 | 58 | plan.users.push(userID); 59 | user.plan = planID; 60 | 61 | await Promise.all([plan.save(), user.save()]); 62 | 63 | return res.status(200).json({ message: "User added to plan successfully.", success: true }); 64 | } 65 | catch (error) { 66 | return res.status(500).json({ message: "Internal server error.", success:false }); 67 | } 68 | }; 69 | -------------------------------------------------------------------------------- /server/index.js: -------------------------------------------------------------------------------- 1 | // Using ES6 imports 2 | // This was mentioned in package.json line:6 3 | 4 | import express from 'express'; 5 | import mongoose from 'mongoose'; 6 | import dotenv from 'dotenv'; 7 | import cors from 'cors'; 8 | 9 | // Importing the Router Files 10 | import welcomeRouter from './routes/welcomeRoute.js'; 11 | import authRoute from './routes/auth-route.js' 12 | import userRoute from './routes/user-route.js' 13 | import adminRoute from './routes/admin-route.js' 14 | import planRoute from './routes/plan-route.js' 15 | import blogRoute from './routes/blog-route.js' 16 | 17 | // Iniliazing Express Server 18 | const server = express(); 19 | const port = 3000; // Port Number 20 | 21 | 22 | 23 | dotenv.config(); 24 | server.use(express.json()); 25 | server.use(cors( 26 | { 27 | origin: "https:localhost:3000", 28 | methods: ["GET", "POST", "PUT", "DELETE"], 29 | credentials: true 30 | })); 31 | 32 | 33 | // Redirecting the routes to the router files 34 | 35 | server.use('/', welcomeRouter); 36 | server.use("/api/auth",authRoute); 37 | server.use("/api/user",userRoute) 38 | server.use('/api/admin',adminRoute) 39 | server.use('/api/plan',planRoute) 40 | server.use('/api/blogs',blogRoute) 41 | 42 | // Response Handler Middleware Which will send response to the client in the form of JSON Object 43 | 44 | server.use((obj, req, res, next) => { 45 | const statuscode = obj.status || 500; 46 | const message = obj.message || "Something went wrong"; 47 | return res.status(statuscode).json({ 48 | success: [200,201,204].some(a=> a === obj.status)? true : false, 49 | status: statuscode, 50 | message: message, 51 | stack: obj.stack, 52 | data: obj.data? obj.data : false 53 | }); 54 | }); 55 | 56 | // Database connection Function 57 | const ConnetMongoDB = async () => { 58 | try { 59 | await mongoose.connect('mongodb://localhost:27017/fitbody'); 60 | console.log('DB connected !'); 61 | } catch (error) { 62 | console.error('Error: ', error); 63 | console.log('DB connection failed'); 64 | } 65 | } 66 | 67 | 68 | // Server Listening 69 | 70 | server.listen(port, function check (error) { 71 | ConnetMongoDB(); 72 | if (error) { 73 | console.error('Error: ', error); 74 | } 75 | else { 76 | console.log(`Server is running on port: ${port}`); 77 | 78 | } 79 | }); -------------------------------------------------------------------------------- /server/middleware/adminMiddleware.js: -------------------------------------------------------------------------------- 1 | import jwt from 'jsonwebtoken' 2 | const isAdminAuthenticated = async(req,res,next) => { 3 | try { 4 | const token=req.header('Authorization'); 5 | if(!token){ 6 | return res.status(401).json({message:"admin not authenticated.",success:false}) 7 | }; 8 | const jwtToken=token.replace("Bearer","").trim(); 9 | const decode = await jwt.verify(jwtToken,process.env.JWT_SECRET_KEY); 10 | if(!decode){ 11 | return res.status(401).json({message:"Invalid token",success:false}); 12 | }; 13 | req.id = decode.adminId; 14 | next(); 15 | } 16 | catch (error) { 17 | return res.status(500).json({ message: "internal server error", error, success: false }) 18 | } 19 | }; 20 | export default isAdminAuthenticated -------------------------------------------------------------------------------- /server/middleware/authMiddleware.js: -------------------------------------------------------------------------------- 1 | import jwt from 'jsonwebtoken' 2 | const isUserAuthenticated = async(req,res,next) => { 3 | try { 4 | const token=req.header('Authorization'); 5 | if(!token){ 6 | return res.status(401).json({message:"User not authenticated.",success:false}) 7 | }; 8 | const jwtToken=token.replace("Bearer","").trim(); 9 | const decode = await jwt.verify(jwtToken,process.env.JWT_SECRET_KEY); 10 | if(!decode){ 11 | return res.status(401).json({message:"Invalid token",success:false}); 12 | }; 13 | req.id = decode.userId; 14 | next(); 15 | } 16 | catch (error) { 17 | return res.status(500).json({ message: "internal server error", error, success: false }) 18 | } 19 | }; 20 | export default isUserAuthenticated -------------------------------------------------------------------------------- /server/models/admin-model.js: -------------------------------------------------------------------------------- 1 | import mongoose from "mongoose"; 2 | 3 | const adminSchema=mongoose.Schema({ 4 | name:{ 5 | type:String, 6 | required:true 7 | }, 8 | email:{ 9 | type:String, 10 | required:true 11 | }, 12 | contact: { 13 | type: String, 14 | unique: true, 15 | required: true, 16 | validate: { 17 | validator: function (value) { 18 | // Check if the value has exactly 10 digits 19 | return /^\d{10}$/.test(value); 20 | }, 21 | }, 22 | }, 23 | password:{ 24 | type:String, 25 | required:true, 26 | }, 27 | 28 | },{timeStamps:true}); 29 | 30 | const Admin = mongoose.model("Admin", adminSchema); 31 | export default Admin; -------------------------------------------------------------------------------- /server/models/blog-model.js: -------------------------------------------------------------------------------- 1 | import mongoose from "mongoose"; 2 | const categories=[ 3 | 'Exercises', 4 | 'Diet plan', 5 | 'Mental Health and Wellness', 6 | 'Trends and Research', 7 | 'Success Stories', 8 | 'Expert Advice', 9 | 'Other' 10 | ] 11 | const blogSchema=mongoose.Schema({ 12 | title:{ 13 | type:String, 14 | required:true 15 | }, 16 | description:{ 17 | type:String, 18 | required:true 19 | }, 20 | author:{ 21 | type: mongoose.Schema.Types.ObjectId, 22 | ref: 'User' 23 | }, 24 | category:{ 25 | type:String, 26 | enum:categories, 27 | required:true 28 | } 29 | },{timestamps:true}) 30 | 31 | const Blog=mongoose.model('Blog',blogSchema) 32 | export default Blog; -------------------------------------------------------------------------------- /server/models/plan-model.js: -------------------------------------------------------------------------------- 1 | import mongoose from 'mongoose'; 2 | 3 | const planModel = mongoose.Schema({ 4 | name: { 5 | type: String, 6 | required: true 7 | }, 8 | description: { 9 | type: String, 10 | required: true 11 | }, 12 | duration: { 13 | type: Number, 14 | required: true 15 | }, 16 | price: { 17 | type: String, 18 | required: true 19 | }, 20 | users: [{ 21 | type: mongoose.Schema.Types.ObjectId, 22 | ref: 'User' 23 | }] 24 | }) 25 | 26 | const Plan = mongoose.model("Plan", planModel); 27 | export default Plan -------------------------------------------------------------------------------- /server/models/user-model.js: -------------------------------------------------------------------------------- 1 | import mongoose from "mongoose"; 2 | import bcrypt from 'bcryptjs' 3 | 4 | const userModel = mongoose.Schema({ 5 | name: { 6 | type: String, 7 | require: true, 8 | }, 9 | password: { 10 | type: "String", 11 | required: true 12 | }, 13 | age: { 14 | type: Number, 15 | required: true 16 | }, 17 | email: { 18 | type: "String", 19 | unique: true, 20 | required: true 21 | }, 22 | isVerified: { 23 | type: Boolean, 24 | default: false 25 | }, 26 | contact: { 27 | type: String, 28 | unique: true, 29 | required: true, 30 | validate: { 31 | validator: function (value) { 32 | // Check if the value has exactly 10 digits 33 | return /^\d{10}$/.test(value); 34 | }, 35 | }, 36 | }, 37 | panNumber: { 38 | type: String, 39 | unique: true, 40 | required: true, 41 | validate: { 42 | validator: function (value) { 43 | // PAN card number validation 44 | // Format: ABCDE1234F (5 uppercase letters, 4 digits, 1 uppercase letter) 45 | return /^[A-Z]{5}[0-9]{4}[A-Z]{1}$/.test(value); 46 | }, 47 | }, 48 | }, 49 | plan: { 50 | type: mongoose.Schema.Types.ObjectId, 51 | ref: 'Plan', 52 | default: null 53 | }, 54 | planStartDate: { 55 | type: String, 56 | default: null 57 | }, 58 | planEndDate: { 59 | type: String, 60 | default: null 61 | }, 62 | blogs: [{ 63 | type: mongoose.Schema.Types.ObjectId, 64 | ref: 'Blog' 65 | }] 66 | }, { timestamps: true }); 67 | 68 | userModel.methods.matchPassword = async function (enteredPassword) { 69 | return await bcrypt.compare(enteredPassword, this.password); 70 | }; 71 | 72 | userModel.pre("save", async function (next) { 73 | if (!this.isModified) { 74 | next(); 75 | } 76 | 77 | const salt = await bcrypt.genSalt(10); 78 | this.password = await bcrypt.hash(this.password, salt); 79 | }); 80 | 81 | const User = mongoose.model("User", userModel); 82 | export default User; 83 | 84 | -------------------------------------------------------------------------------- /server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1", 9 | "start": "nodemon index.js" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "ISC", 14 | "dependencies": { 15 | "bcryptjs": "^2.4.3", 16 | "cookie-parser": "^1.4.6", 17 | "cors": "^2.8.5", 18 | "dotenv": "^16.4.5", 19 | "express": "^4.19.2", 20 | "jsonwebtoken": "^9.0.2", 21 | "mongoose": "^8.3.4", 22 | "nodemon": "^3.1.0", 23 | "zod": "^3.23.8" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /server/routes/admin-route.js: -------------------------------------------------------------------------------- 1 | import express from 'express'; 2 | import { adminLogin, changePassword, registerAdmin } from '../controllers/admin-controller.js' 3 | import { RegisterSchema, LoginSchema } from '../validation/zodschema.js'; 4 | import { validate } from '../validation/validation.schema.js'; 5 | const router = express.Router(); 6 | 7 | router.post('/register', validate(RegisterSchema), registerAdmin); 8 | router.post('/login', validate(LoginSchema), adminLogin); 9 | router.post('/resetpassword',changePassword) 10 | 11 | 12 | export default router; -------------------------------------------------------------------------------- /server/routes/auth-route.js: -------------------------------------------------------------------------------- 1 | import express from 'express'; 2 | import { registerUser, authUser, changePassword } from '../controllers/auth-controller.js'; 3 | import { RegisterSchema, LoginSchema } from '../validation/zodschema.js'; 4 | import { validate } from '../validation/validation.schema.js'; 5 | const router = express.Router(); 6 | 7 | router.post('/register',validate(RegisterSchema), registerUser); 8 | router.post('/login',validate(LoginSchema) ,authUser); 9 | router.post('/resetpassword',changePassword) 10 | 11 | 12 | export default router; -------------------------------------------------------------------------------- /server/routes/blog-route.js: -------------------------------------------------------------------------------- 1 | import express from 'express' 2 | import { addBlog, deleteBlog, getBlog, getBlogsByCategory, getUserBlogs, showAllBlogs, updateBlog } from '../controllers/blogs-controller.js'; 3 | import isUserAuthenticated from '../middleware/authMiddleware.js'; 4 | 5 | 6 | const router=express.Router() 7 | 8 | router.post('/',isUserAuthenticated,addBlog) 9 | router.delete('/:id',deleteBlog) 10 | router.get('/',showAllBlogs) 11 | router.get('/:id',getBlog) 12 | router.get('/getuserblogs',isUserAuthenticated,getUserBlogs) 13 | router.put('/:id',isUserAuthenticated,updateBlog) 14 | router.get('/getbycategory/:category',getBlogsByCategory) 15 | 16 | export default router; -------------------------------------------------------------------------------- /server/routes/plan-route.js: -------------------------------------------------------------------------------- 1 | import express from 'express'; 2 | import {addPlan, deletePlan, getAllPlans, getPlanDetails, getPlanUsers} from '../controllers/plan-controller.js' 3 | import isAdminAuthenticated from '../middleware/adminMiddleware.js'; 4 | 5 | const router=express.Router() 6 | 7 | router.post('/',isAdminAuthenticated,addPlan) 8 | router.get('/',getAllPlans) 9 | router.get('/:id',getPlanDetails) 10 | router.delete('/:id',isAdminAuthenticated,deletePlan) 11 | router.get('/plan_users/:id',isAdminAuthenticated,getPlanUsers) 12 | 13 | export default router; -------------------------------------------------------------------------------- /server/routes/user-route.js: -------------------------------------------------------------------------------- 1 | import express from 'express'; 2 | import { addUserToPlan, getAllUsers, userDetails } from '../controllers/user-controller.js'; 3 | import isUserAuthenticated from '../middleware/authMiddleware.js'; 4 | 5 | const router=express.Router() 6 | 7 | router.get('/:id',userDetails) 8 | router.get('/',getAllUsers) 9 | router.post('/:id',isUserAuthenticated,addUserToPlan) 10 | 11 | export default router; -------------------------------------------------------------------------------- /server/routes/welcomeRoute.js: -------------------------------------------------------------------------------- 1 | import { Router } from 'express'; 2 | var router = Router(); 3 | 4 | /* GET home page. */ 5 | router.get('/', function(req, res, next) { 6 | return res.send("

Hello Welcome to Fitbody

"); 7 | }); 8 | 9 | export default router; -------------------------------------------------------------------------------- /server/validation/validation.schema.js: -------------------------------------------------------------------------------- 1 | const validate = (schema) => async (req, res, next) => { 2 | try { 3 | const parsedBody = await schema.parseAsync(req.body); 4 | req.body = parsedBody; 5 | next(); 6 | } catch (err) { 7 | console.log(err); 8 | const yourerror = err.errors[0].message; 9 | res.status(400).json({ 10 | msg: yourerror, 11 | }); 12 | } 13 | } 14 | export { validate }; -------------------------------------------------------------------------------- /server/validation/zodschema.js: -------------------------------------------------------------------------------- 1 | import zod from "zod"; 2 | 3 | const RegisterSchema = zod.object({ 4 | name: zod 5 | .string({ required_error: "Username is required" }) 6 | .trim() 7 | .min(3, { message: "Username must be at least 3 characters" }) 8 | .max(255, { message: "Username can be at most 255 characters" }), 9 | email: zod 10 | .string({ required_error: "Email is required" }) 11 | .trim() 12 | .email({ message: "Invalid email address" }) 13 | .min(3, { message: "Email should be at least 3 characters" }) 14 | .max(255, { message: "Email can be at most 255 characters" }), 15 | password: zod 16 | .string({ required_error: "Password is required" }) 17 | .trim() 18 | .min(7, { message: "Password must be at least 7 characters" }) 19 | .max(1024, { message: "Password must be at most 1024 characters" }), 20 | contact: zod 21 | .string({ required_error: "Contact number is required" }) 22 | .trim() 23 | .regex(/^\d{10}$/, { message: "Contact number must be exactly 10 digits" }) 24 | }); 25 | 26 | const LoginSchema = zod.object({ 27 | email: zod 28 | .string({ required_error: "Email is required" }) 29 | .trim() 30 | .email({ message: "Invalid email address" }) 31 | .min(3, { message: "Email should be at least 3 characters" }) 32 | .max(255, { message: "Email can be at most 255 characters" }), 33 | password: zod 34 | .string({ required_error: "Password is required" }) 35 | .trim() 36 | .min(7, { message: "Password must be at least 7 characters" }) 37 | .max(1024, { message: "Password must be at most 1024 characters" }), 38 | }); 39 | 40 | export { RegisterSchema, LoginSchema }; -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | /* google fonts */ 2 | @import url("https://fonts.googleapis.com/css2?family=Questrial&display=swap"); 3 | @import 'font-awesome/css/font-awesome.min.css'; 4 | 5 | :root { 6 | --primary-color: #6f55f2; 7 | --heading-color: #132742; 8 | --bg-gradient: linear-gradient( 9 | 90deg, 10 | rgba(103, 101, 240, 1) 27%, 11 | rgba(141, 141, 235, 1) 85% 12 | ); 13 | --font-name: "Questrial", sans-serif; 14 | } 15 | 16 | * { 17 | margin: 0; 18 | padding: 0; 19 | box-sizing: border-box; 20 | } 21 | 22 | 23 | /* Styles for light mode */ 24 | .light-mode-app { 25 | background-color: #f7f7f7; 26 | color: #333; 27 | } 28 | 29 | /* Styles for dark mode */ 30 | .dark-mode-app { 31 | background-color:#111; 32 | color:#f7f7f7 33 | } 34 | 35 | @media (max-width: 768px) { 36 | .dark-mode-app, 37 | .light-mode-app { 38 | overflow-x: hidden; 39 | } 40 | } 41 | 42 | 43 | 44 | /* Common styles for both modes */ 45 | /* ... */ 46 | 47 | 48 | *::-webkit-scrollbar { 49 | height: 4px; 50 | width: 4px; 51 | } 52 | *::-webkit-scrollbar-track { 53 | border-radius: 6px; 54 | background-color: #D3DCDE; 55 | } 56 | 57 | *::-webkit-scrollbar-track:hover { 58 | background-color: #DCE6E8; 59 | } 60 | 61 | *::-webkit-scrollbar-track:active { 62 | background-color: #B8C0C2; 63 | } 64 | 65 | *::-webkit-scrollbar-thumb { 66 | border-radius: 10px; 67 | background-color: #8D90C3; 68 | } 69 | 70 | *::-webkit-scrollbar-thumb:hover { 71 | background-color: #8D90C3; 72 | } 73 | 74 | *::-webkit-scrollbar-thumb:active { 75 | background-color: #8D90C3; 76 | } 77 | -------------------------------------------------------------------------------- /src/App.jsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from "react"; 2 | import Aos from "aos"; 3 | import "./App.css"; 4 | import About from "./components/UI/About"; 5 | import Header from "./components/Header/Header"; 6 | import Exercises from "./components/UI/Exercises"; 7 | import Footer from "./components/UI/Footer"; 8 | import Hero from "./components/UI/Hero"; 9 | import Pricing from "./components/UI/Pricing"; 10 | import Start from "./components/UI/Start"; 11 | import Testimonials from "./components/UI/Testimonials"; 12 | import ContactUs from "./components/UI/ContactUs"; 13 | import BackToTop from "./components/UI/BackToTop"; 14 | import LocomotiveScroll from 'locomotive-scroll'; 15 | import Classes from "./components/UI/Classes"; 16 | import Diet from "./components/UI/Diet"; 17 | 18 | import Register from "./components/UI/Register"; 19 | import Login from "./components/UI/Login"; 20 | 21 | import PrivacyPolicy from "./components/UI/privacypolicy"; 22 | import Licensing from "./components/UI/Licensing"; 23 | import TermsAndConditions from "./components/UI/termsandconditions"; 24 | 25 | import { BrowserRouter as Router , Routes, Route } from "react-router-dom"; 26 | import Error from "./components/UI/Error"; 27 | 28 | 29 | 30 | 31 | function App() { 32 | const locomotiveScroll = new LocomotiveScroll(); 33 | useEffect(() => { 34 | Aos.init(); 35 | }, []); 36 | 37 | const [isDarkMode, setDarkMode] = useState(() => localStorage.getItem('darkMode') === 'true'); 38 | 39 | useEffect(() => { 40 | localStorage.setItem('darkMode', isDarkMode); 41 | }, [isDarkMode]); 42 | 43 | return ( 44 | <> 45 | 46 | 47 | 48 |
49 | 50 | 51 | 52 | 53 | 54 | 55 |