This repository contains the backend for the Recipe Sharing Website. The backend is built with Node.js, Express.js, and MongoDB Atlas. It handles user authentication, authorization, and recipe management.
- Users can create, and delete recipes.
- Recipes are categorized into multiple categories.
- Authentication with JWT.
- Password hashing with bcryptjs.
- Database: MongoDB Atlas with Mongoose for data modeling.
- Node.js: JavaScript runtime for building the server-side of the application.
- Express.js: Web framework for routing and handling requests.
- MongoDB Atlas: Cloud database for storing recipes and user data.
- Mongoose: ODM (Object Data Modeling) for interacting with MongoDB.
- JWT: JSON Web Token for user authentication and authorization.
- bcryptjs: Password hashing for securing user accounts.
The fronend for this project is available here.
- Node.js (v14+)
- npm (Node Package Manager)
- MongoDB Atlas account
- Clone the repository:
git clone https://github.com/Tami-Co/Server_side_recipe_project.git
- Install server dependencies:
cd server-side npm install
- Environment variables: Create a .env file in the server-side folder with the following content:
PORT=<your-port> DB_URL=<your-mongodb-url> BCRYPT_SALT=<your-bcrypt-salt> JWT_SECRET=<your-secret-key>
- Run the backend (server):
npm run dev
url | method | description | permissions | parameters | optional parameters | body | headers | returns | status codes |
---|---|---|---|---|---|---|---|---|---|
http://localhost:5000/users/ | GET | get all users | administrator | --- | --- | --- | token | all users | 200 |
http://localhost:5000/users/signin | POST | user sign ip | --- | --- | --- | {email,password} | --- | User+token | 204 |
http://localhost:5000/users/signup | POST | user sign up | --- | --- | --- | {username,email,password,addres} | --- | User+token | 204 |
http://localhost:5000/users/:userId | GET | get user by id | administrator /current user | {userId} – קוד משתמש | --- | --- | token | User | 200 |
url | method | description | permissions | parameters | optional parameters | body | headers | returns | status codes |
---|---|---|---|---|---|---|---|---|---|
http://localhost:5000/recipes | GET | get all recipes | --- | --- | perPage - מס' מתכונים לעמוד page - מס' עמוד search - חיפוש לפי שם מתכון | --- | --- | all recipes by sorted | 200 |
http://localhost:5000/:id | GET | get recipe by id | --- | {id} – קוד מתכון | --- | --- | --- | recipe by id | 200 |
http://localhost:5000/recipes/recipesUser/:idUser | GET | get recipes of user - by id of user | administrator /current user | {idUser} – קוד משתמש | --- | --- | token | recipe by user id | 200 |
http://localhost:5000/recipes/recipesByTime/:time | GET | get recipes by preparation time | --- | {time} – זמן הכנה | --- | --- | --- | recipes by time | 200 |
http://localhost:5000/recipes | POST | add new course | administrator /current user | --- | --- | { new recipe} | token | new recipe added | 204 |
http://localhost:5000/recipes/:id | PUT | update existing recipe (by id) | administrator /current user | {id} – קוד מתכון | --- | {recipe} | token | updated recipe | 204 |
http://localhost:5000/recipes/:id | DELETE | delete existing recipe (by id) | administrator /current user | {id} – קוד מתכון | --- | --- | token | --- | 204 |
url | method | description | permissions | parameters | optional parameters | body | headers | returns | status codes |
---|---|---|---|---|---|---|---|---|---|
http://localhost:5000/categories | GET | get all categories | --- | --- | --- | --- | all category | 200 | |
http://localhost:5000/categories/withRecipes | GET | get all categories with their recipes | --- | --- | --- | --- | --- | all category with recipes | 200 |
http://localhost:5000/categories/:name | GET | get category with her recipes by name of category | --- | {name} – שם קטגוריה | --- | --- | --- | category by name with recipes | 200 |