Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/preetiraj3697/recipe-finder-backend


https://github.com/preetiraj3697/recipe-finder-backend

Last synced: 25 days ago
JSON representation

Awesome Lists containing this project

README

        

Sure, here's an example of how you can structure your backend README file to include information about routes, APIs, and how to use the search functionality:

---

# Recipe Finder Backend

Welcome to the Recipe Finder backend! This backend service provides APIs to manage recipes, including creating, fetching, and searching recipes.

## Getting Started

To get started with the Recipe Finder backend, follow these steps:

1. Clone the repository:

```bash
git clone
cd recipe-finder-backend
```

2. Install dependencies:

```bash
npm install
```

3. Set up environment variables:

Create a `.env` file in the root directory and add the following environment variables:

```env
PORT=8000
MONGODB_URI=
CORS_ORIGIN=http://localhost:3000 # Update with your frontend URL
```

4. Start the server:

```bash
npm start
```

## Routes and APIs

### Fetch All Recipes

- **URL:** `/api/recipes`
- **Method:** GET
- **Description:** Retrieves all recipes stored in the database.
- **Sample Response:**
```json
[
{
"_id": "662f51b06201487016c64a1b",
"name": "Spaghetti Carbonara",
"minutes": "30",
"tags": [
"Italian",
"Pasta",
"Carbonara"
],
"nutrition": [
450,
25,
8,
2,
60,
5,
12
],
"n_steps": "5",
"steps": [
"Boil water",
"Cook pasta",
"Prepare sauce",
"Combine pasta and sauce",
"Serve"
],
"description": "Classic Italian pasta dish with creamy sauce made from eggs, cheese, pancetta, and black pepper.",
"ingredients": [
"Spaghetti",
"Eggs",
"Pancetta or bacon",
"Parmesan cheese",
"Black pepper",
"Salt"
],
"n_ingredients": 6
},
{
"_id": "662f586b02d841c928259774",
"name": "Lasagna",
"minutes": "60",
"tags": [
"Italian",
"Pasta",
"Baked"
],
"nutrition": [
550,
30,
15,
5,
70,
7,
18
],
"n_steps": "6",
"steps": [
"Prepare meat sauce",
"Cook lasagna noodles",
"Layer noodles, sauce, and cheese",
"Repeat layering",
"Bake in oven",
"Serve hot"
],
"description": "Classic Italian baked pasta dish with layers of meat sauce, cheese, and lasagna noodles.",
"ingredients": [
"Lasagna noodles",
"Ground beef",
"Tomato sauce",
"Ricotta cheese",
"Mozzarella cheese",
"Parmesan cheese",
"Garlic",
"Onion",
"Olive oil"
],
"n_ingredients": 9
},
{
"_id": "662f590dc542ce2a2b6f1f90",
"name": "Lasagna",
"minutes": "60",
"tags": [
"Italian",
"Pasta",
"Baked"
],
"nutrition": [
550,
30,
15,
5,
70,
7,
18
],
"n_steps": "6",
"steps": [
"Prepare meat sauce",
"Cook lasagna noodles",
"Layer noodles, sauce, and cheese",
"Repeat layering",
"Bake in oven",
"Serve hot"
],
"description": "Classic Italian baked pasta dish with layers of meat sauce, cheese, and lasagna noodles.",
"ingredients": [
"Lasagna noodles",
"Ground beef",
"Tomato sauce",
"Ricotta cheese",
"Mozzarella cheese",
"Parmesan cheese",
"Garlic",
"Onion",
"Olive oil"
],
"n_ingredients": 9,
"__v": 0
}]
```

### Create a New Recipe

- **URL:** `/api/recipes`
- **Method:** POST
- **Description:** Creates a new recipe and adds it to the database.
- **Request Body:**
```json
{
"name": "Margherita Pizza",
"minutes": "25",
"tags": ["Italian", "Pizza"],
"nutrition": [400, 15, 10, 3, 30, 2, 12],
"n_steps": "4",
"steps": ["Prepare pizza dough", "Spread tomato sauce and cheese on dough", "Bake in oven", "Top with fresh basil leaves before serving"],
"description": "Classic Italian pizza with simple toppings of tomato sauce, fresh mozzarella cheese, and basil leaves.",
"ingredients": ["Pizza dough", "Tomato sauce", "Fresh mozzarella cheese", "Fresh basil leaves", "Olive oil", "Salt"],
"n_ingredients": 6}
```
- **Sample Response:** `"Created the new recipe"`

### Search Recipes by Name

- **URL:** `/api/recipes/search?name=`
- **Method:** GET
- **Description:** Searches for recipes by name.
- **Sample Request:** `/api/recipes/search?name=chicken`
- **Sample Response:**
```json
[
{
"_id": "662f598ac542ce2a2b6f1f95",
"name": "Chicken Alfredo",
"minutes": "45",
"tags": [
"Italian",
"Pasta",
"Creamy"
],
"nutrition": [
600,
35,
20,
8,
50,
4,
22
],
"n_steps": "5",
"steps": [
"Cook pasta",
"Saute chicken",
"Prepare Alfredo sauce",
"Combine pasta, chicken, and sauce",
"Serve with grated cheese and parsley"
],
"description": "Creamy Italian pasta dish with tender chicken and rich Alfredo sauce.",
"ingredients": [
"Fettuccine pasta",
"Chicken breast",
"Heavy cream",
"Butter",
"Parmesan cheese",
"Garlic",
"Salt",
"Pepper"
],
"n_ingredients": 8,
"__v": 0
},
{
"_id": "662f5b729567e37440f150f9",
"name": "Chicken Tikka",
"minutes": "45",
"tags": [
"Indian",
"Chicken",
"Grilled"
],
"nutrition": [
400,
20,
10,
3,
40,
2,
15
],
"n_steps": "4",
"steps": [
"Marinate chicken",
"Grill chicken",
"Prepare masala",
"Toss chicken in masala before serving"
],
"description": "Popular Indian appetizer made by marinating chicken chunks in yogurt and spices, and then grilling until tender and juicy.",
"ingredients": [
"Chicken breast",
"Yogurt",
"Ginger-garlic paste",
"Spices (cumin, coriander, turmeric, paprika)",
"Lemon juice",
"Oil",
"Salt"
],
"n_ingredients": 7,
"__v": 0
}]```

## Contributing

Contributions are welcome! If you find any bugs or have suggestions for improvements, please open an issue or submit a pull request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.