Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/bhavnesh7781/Food-Delivery-App/llms.txt

Use this file to discover all available pages before exploring further.

The Food API provides three endpoints for managing the restaurant’s menu. These are used by both the admin dashboard (to add/remove items) and the customer frontend (to list items). Image files are handled automatically by Multer and stored on the server’s local filesystem under backend/uploads/.

POST /api/food/add

Adds a new food item to the menu. This is a multipart/form-data request because it includes an image file upload. Multer stores the image in the uploads/ directory using the filename pattern <timestamp><originalname> — only the resulting filename (not the full path) is saved in MongoDB.
This endpoint does not require authentication in the current implementation. Restrict access to admin roles before deploying to production.
Content-Type: multipart/form-data

Request Body

name
string
required
The display name of the food item (e.g., "Caesar Salad").
description
string
required
A short description of the food item shown on the menu card.
price
number
required
Price of the item in INR (e.g., 199).
category
string
required
Menu category the item belongs to. Must be one of: Salad, Rolls, Deserts, Sandwich, Cake, Pure Veg, Pasta, Noodles.
image
file
required
The food item image file. Accepted via the image form field. Stored in backend/uploads/ as <timestamp><originalname> (e.g., 1716300000000burger.png).

Response

success
boolean
true when the item was saved successfully, false on error.
message
string
"Food Added" on success, "Error" on failure.
{ "success": true, "message": "Food Added" }

Example

curl -X POST http://localhost:4000/api/food/add \
  -F "name=Caesar Salad" \
  -F "description=Fresh romaine lettuce with Caesar dressing and croutons" \
  -F "price=199" \
  -F "category=Salad" \
  -F "image=@/path/to/caesar.jpg"

GET /api/food/list

Returns all food items currently in the database. This is the primary data source for the customer-facing menu page. No request parameters are required.
Food item images are not embedded in the response. The image field contains only the stored filename (e.g., "1716300000000caesar.jpg"). Serve the actual image by appending the filename to the /images/ route: GET /images/<filename>.

Response

success
boolean
true when the list was fetched successfully.
data
array
Array of all food item documents from MongoDB.
{
  "success": true,
  "data": [
    {
      "_id": "6641a3f2e4b0c123456789ab",
      "name": "Caesar Salad",
      "description": "Fresh romaine lettuce with Caesar dressing and croutons",
      "price": 199,
      "category": "Salad",
      "image": "1716300000000caesar.jpg"
    }
  ]
}

Example

curl -X GET http://localhost:4000/api/food/list

POST /api/food/remove

Removes a food item from the menu by its MongoDB _id. The controller first resolves the item’s stored image filename, deletes the file from the uploads/ directory on disk using fs.unlink, and then removes the document from MongoDB.
This endpoint does not require authentication in the current implementation. Restrict access to admin roles before deploying to production.

Request Body

id
string
required
The MongoDB _id of the food item to remove (e.g., "6641a3f2e4b0c123456789ab").

Response

success
boolean
true when the item and its image were removed successfully.
message
string
"Food Removed" on success, "Error" on failure.
{ "success": true, "message": "Food Removed" }

Example

curl -X POST http://localhost:4000/api/food/remove \
  -H "Content-Type: application/json" \
  -d '{ "id": "6641a3f2e4b0c123456789ab" }'

Build docs developers (and LLMs) love