Skip to main content
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

string
required
The display name of the food item (e.g., "Caesar Salad").
string
required
A short description of the food item shown on the menu card.
number
required
Price of the item in INR (e.g., 199).
string
required
Menu category the item belongs to. Must be one of: Salad, Rolls, Deserts, Sandwich, Cake, Pure Veg, Pasta, Noodles.
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

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

Example


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

boolean
true when the list was fetched successfully.
array
Array of all food item documents from MongoDB.

Example


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

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

Response

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

Example