This is a simple Recipes management API.
To run this api: Step-1
npm install
Step-2
npm run dev
The project provides the following API endpoints:
create a new user.
Request:
{
"name": "John Doe",
"email": "johndoe@example.com",
"password": "password123"
}
Response:
{
"status": true,
"message": "Successfully created account!"
}
login a user.
Request:
{
"email": "johndoe@example.com",
"password": "password123"
}
Response:
{
"auth": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NDczODI2ZjI2OGM3NjQ0OTBmMjBiNjIiLCJpYXQiOjE2ODUyOTkxNTksImV4cCI6MTY4NTM4NTU1OX0.qs_RkR_anz-oqyJApfi4OmD4TI-Wfl6HzzngwpL8uX4",
"message": "Log in succussfully!"
}
for creating recipe by the user.
Request:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NDczODI2ZjI2OGM3NjQ0OTBmMjBiNjIiLCJpYXQiOjE2ODUyOTkxNTksImV4cCI6MTY4NTM4NTU1OX0.qs_RkR_anz-oqyJApfi4OmD4TI-Wfl6HzzngwpL8uX4",
"title": "Testing 2",
"description": "description for testing",
"ingredients": [],
"instructions": []
}
Response:
{
"status": true,
"recipeId": "6473a11a0627cea08a5d92d2",
"message": "Recipe has been created successfully!"
}
get all recipes that were created by a user.
Request:
GET /api/v1/recipe/getAllRecipes/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NDczODI2ZjI2OGM3NjQ0OTBmMjBiNjIiLCJpYXQiOjE2ODUyOTkxNTksImV4cCI6MTY4NTM4NTU1OX0.qs_RkR_anz-oqyJApfi4OmD4TI-Wfl6HzzngwpL8uX4
Response:
{
"status": true,
"data": [
{
"_id": "6473a0970627cea08a5d92cf",
"userId": "6473826f268c764490f20b62",
"title": "Testing 1",
"description": "description for testing",
"ingredients": [
"First Ingredient",
"Second Ingredient"
],
"instructions": [
"First Instruction",
"Second Instruction"
],
"createdAt": "2023-05-28T18:38:52.387Z",
"__v": 0,
"updatedAt": "2023-05-28T18:50:22.516Z"
},
{
"_id": "6473a0970627cea08a3frcd",
"userId": "6473826f268c764490f20b62",
"title": "Testing 2",
"description": "description for testing",
"ingredients": [],
"instructions": [],
"createdAt": "2023-05-28T18:40:52.387Z",
"__v": 0
}
]
}
get a particular recipe that was created by a user.
Request:
GET /api/v1/recipe/getRecipe/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NDczODI2ZjI2OGM3NjQ0OTBmMjBiNjIiLCJpYXQiOjE2ODUyOTkxNTksImV4cCI6MTY4NTM4NTU1OX0.qs_RkR_anz-oqyJApfi4OmD4TI-Wfl6HzzngwpL8uX4/6473a11a0627cea08a5d92d2
Response:
{
"status": true,
"data": [
{
"_id": "6473a11a0627cea08a5d92d2",
"userId": "6473826f268c764490f20b62",
"title": "Testing 2",
"description": "description for testing",
"ingredients": [],
"instructions": [],
"createdAt": "2023-05-28T18:38:52.387Z",
"__v": 0
}
]
}
update a particular recipe that was created by a user.
Request:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NDczODI2ZjI2OGM3NjQ0OTBmMjBiNjIiLCJpYXQiOjE2ODUyOTkxNTksImV4cCI6MTY4NTM4NTU1OX0.qs_RkR_anz-oqyJApfi4OmD4TI-Wfl6HzzngwpL8uX4",
"recipeId": "6473a0970627cea08a5d92cf",
"title": "Testing 1",
"description": "description for testing",
"ingredients": [],
"instructions": []
}
Response:
{
"status": true,
"message": "Recipe has been updated successfully!"
}
for adding ingredient in recipe by user.
Request:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NDczODI2ZjI2OGM3NjQ0OTBmMjBiNjIiLCJpYXQiOjE2ODUyOTkxNTksImV4cCI6MTY4NTM4NTU1OX0.qs_RkR_anz-oqyJApfi4OmD4TI-Wfl6HzzngwpL8uX4",
"recipeId": "6473a0970627cea08a5d92cf",
"ingredient": "First Ingredient"
}
Response:
{
"status": true,
"message": "New Ingredient has been added successfully!"
}
for adding ingredient in recipe by user.
Request:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NDczODI2ZjI2OGM3NjQ0OTBmMjBiNjIiLCJpYXQiOjE2ODUyOTkxNTksImV4cCI6MTY4NTM4NTU1OX0.qs_RkR_anz-oqyJApfi4OmD4TI-Wfl6HzzngwpL8uX4",
"recipeId": "6473a0970627cea08a5d92cf",
"instruction": "Second Instruction"
}
Response:
{
"status": true,
"message": "New Instruction has been added successfully!"
}
for deletion of recipe that was created by user.
Request:
DELETE /api/v1/recipe/deleteRecipe/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NDczODI2ZjI2OGM3NjQ0OTBmMjBiNjIiLCJpYXQiOjE2ODUyOTkxNTksImV4cCI6MTY4NTM4NTU1OX0.qs_RkR_anz-oqyJApfi4OmD4TI-Wfl6HzzngwpL8uX4/6473a11a0627cea08a5d92d2
Response:
{
"status": true,
"message": "recipe has been deleted successfully!",
"info": {
"acknowledgement": true,
"deletedCount": 1
}
}
The following environment variables can be set to configure the project:
{
"PORT": 3000,
"SERVER_URL": "http://localhost:3000",
"MONGO_URI": "Your MONGODB_URI",
"JWT_SECRET": "Your JWT_SECRET Key",
"AES_SECRET": "Your AES_SECRET key"
}
Name: Abhisekh Upadhaya Email: Abhisek0721@gmail.com