This document outlines the API endpoints for a Grocery Booking application, categorized by role responsibilities: Admin and User.
All URLs referenced in the documentation have the base path:
Most endpoints require authentication. Authentication is performed via JWT tokens. Include the token in the Authorization header:
- Admin: Responsible for managing grocery items and inventory.
- User: Can view grocery items and place orders.
- POST
/items
- Headers:
Authorization: Bearer <token>
- Body: Array of items
[{"name": "Milk", "price": 3.99, "inventory": 100}, ...]
- Description: Adds new grocery items to the system.
- GET
/item
- Headers:
Authorization: Bearer <token>
- Query Parameters:
page
,pageSize
,excludeDeleted
- Description: Retrieves a paginated list of grocery items.
- DELETE
/item
- Headers:
Authorization: Bearer <token>
- Query Parameters:
id
(item ID) - Description: Removes a grocery item from the system.
- PUT
/item
- Headers:
Authorization: Bearer <token>
- Body: Item details
{ "id": 1, "name": "Milk", "price": 4.99 }
- Description: Updates details of an existing grocery item.
- PATCH
/item
- Headers:
Authorization: Bearer <token>
- Body: Inventory update
{ "id": 1, "inventory": 150 }
- Description: Updates the inventory level of a grocery item.
- GET
/items
- Headers: Optional
Authorization: Bearer <token>
for users - Description: Gets a list of all available grocery items.
- POST
/order
- Headers:
Authorization: Bearer <token>
- Body: Order details
{ "orderItems": [{"itemId": 1, "quantity": 2}, ...] }
- Description: Places a new order with multiple grocery items.
- POST
/api/login
- Body:
{ "email": "[email protected]", "password": "password123" }
- Description: Authenticates a user and returns a JWT token.
- POST
/api/signup
- Body:
{ "email": "[email protected]", "password": "password123", "role": "user", "name": "John Doe" }
- Description: Registers a new user and returns a JWT token.
- npm install
- npm run dev