Introduction
Welcome to the WPU Cafe API documentation. This API allows you to access menu items and manage orders for our cafe.
Base URL:
https://wpu-cafe.vercel.app/api
Authentication
Authentication is required for accessing order endpoints. Use the login endpoint to get a JWT token, then include it in the Authorization header of your requests.
POST
/api/auth/login
Login
Authenticate and get an access token.
Request Body:
{ "email": "admin@wpucafe.com", "password": "Admin123" }
Example Response:
{ "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "user": { "id": "123e4567-e89b-12d3-a456-426614174000", "email": "admin@wpucafe.com", "name": "Admin" } }
Error Responses:
Invalid credentials (401):
{ "error": "Invalid credentials" }
Missing or invalid token (401):
{ "error": "Missing authorization header" }
Protected Endpoints:
The following endpoints require authentication:
- GET /api/orders
- POST /api/orders
- GET /api/orders/[id]
- PUT /api/orders/[id]
- DELETE /api/orders/[id]
Headers Usage For Protected Endpoints:
{ "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." }
Endpoints
GET
/api/menu
Get Menu List
Returns a paginated list of menu items.
Query Parameters:
page
- Page number (default: 1)pageSize
- Items per page (default: 10, max: 50)search
- Search in name and descriptioncategory
- Filter by categorysortBy
- Sort by: name, price, categorysortOrder
- Sort order: asc, desc
Example Response:
{ "data": [ { "id": "789e4567-e89b-12d3-a456-426614174000", "name": "Cappuccino", "description": "Espresso with steamed milk and foam", "price": 4.50, "image_url": "https://example.com/cappuccino.jpg", "category": "Coffee", "is_available": true, "created_at": "2024-03-03T12:00:00Z" } ], "metadata": { "total": 20, "page": 1, "pageSize": 10, "totalPages": 2 } }
GET
/api/menu/[id]
Get Menu Item Detail
Returns details of a specific menu item.
Example Response:
{ "menuItem": { "id": "789e4567-e89b-12d3-a456-426614174000", "name": "Cappuccino", "description": "Espresso with steamed milk and foam", "price": 4.50, "image_url": "https://example.com/cappuccino.jpg", "category": "Coffee", "is_available": true, "created_at": "2024-03-03T12:00:00Z" }, "reviews": { "items": [ { "id": "456e4567-e89b-12d3-a456-426614174000", "reviewer_name": "Jane Smith", "rating": 5, "comment": "Best coffee in town!", "created_at": "2024-03-03T12:00:00Z" } ], "total": 10, "averageRating": 4.5 } }
POST
/api/orders
Create Order
Create a new order.
Request Body:
{ "customerName": "John Doe", "tableNumber": 5, "cart": [ { "menuItemId": "item-uuid", "quantity": 2, "notes": "Extra hot" } ] }
GET
/api/orders
Get Orders
Returns a paginated list of orders.
Query Parameters:
page
- Page number (default: 1)pageSize
- Items per page (default: 10, max: 50)search
- Search by customer namestatus
- Filter by status (PROCESSING, COMPLETED)sortBy
- Sort by: created_at, customerName, tableNumber, total, statussortOrder
- Sort order: asc, desc
Example Response:
{ "data": [ { "id": "123e4567-e89b-12d3-a456-426614174000", "customer_name": "John Doe", "table_number": 5, "cart": [ { "menuItemId": "789e4567-e89b-12d3-a456-426614174000", "quantity": 2, "notes": "Extra hot" } ], "status": "PENDING", "total": 9.00, "created_at": "2024-03-03T12:00:00Z", "updated_at": "2024-03-03T12:00:00Z" } ], "metadata": { "total": 50, "page": 1, "pageSize": 10, "totalPages": 5 } }
GET
/api/orders/[id]
Get Order Detail
Returns details of a specific order.
Example Response:
{ "id": "c63ed549-5510-4e79-b16d-074efcf69d58", "customer_name": "Avip", "table_number": 1, "cart": [ { "quantity": 1, "notes": "", "menuItem": { "id": "6e271718-1768-449e-8d53-0e621696512e", "name": "Americano", "description": "Espresso diluted with hot water", "price": 3.5, "image_url": "https://images.unsplash.com/photo-1551030173-122aabc4489c", "category": "Coffee", "is_available": true, "created_at": "2025-03-02T14:44:14.264692+00:00" } }, ], "status": "PROCESSING", "total": 9.5, "created_at": "2025-03-06T23:20:00.390197+00:00", "updated_at": "2025-03-06T23:20:00.390197+00:00" }
PUT
/api/orders/[id]
Update Order Status
Update the status of an order.
Request Body:
{ "status": "COMPLETED" }
DELETE
/api/orders/[id]
Delete Order
Delete an order.
POST
/api/reviews
Create Review
Create a new review for a menu item.
Request Body:
{ "menuItemId": "item-uuid", "reviewerName": "John Smith", "rating": 5, "comment": "Excellent coffee, would order again!" }
GET
/api/reviews
Get Reviews
Returns a paginated list of reviews.
Query Parameters:
page
- Page number (default: 1)pageSize
- Items per page (default: 10, max: 50)menuItemId
- Filter by menu itemminRating
- Minimum rating (1-5)sortBy
- Sort by: created_at, ratingsortOrder
- Sort order: asc, desc
Example Response:
{ "data": [ { "id": "456e4567-e89b-12d3-a456-426614174000", "menu_item_id": "789e4567-e89b-12d3-a456-426614174000", "reviewer_name": "Jane Smith", "rating": 5, "comment": "Best coffee in town!", "created_at": "2024-03-03T12:00:00Z" } ], "metadata": { "total": 30, "page": 1, "pageSize": 10, "totalPages": 3 } }