0xPratikPatil/split-app

★ 0Forks 0TypeScriptGitHub ↗Compare

README

npm install
npm run dev
open http://localhost:3000
### API Endpoints for Testing (assuming server runs on http://localhost:3000)

#### Add Expense - Dinner (₹600, paid by Shantanu)

```bash
curl -X POST http://localhost:3000/api/expenses \
-H "Content-Type: application/json" \
-d '{
  "amount": 600,
  "description": "Dinner",
  "paidBy": "Shantanu",
  "participants": ["Shantanu", "Sanket", "Om"],
  "splitType": "equal"
}'

Add Expense - Groceries (₹450, paid by Sanket)

curl -X POST http://localhost:3000/api/expenses \
-H "Content-Type: application/json" \
-d '{
  "amount": 450,
  "description": "Groceries",
  "paidBy": "Sanket",
  "participants": ["Shantanu", "Sanket", "Om"],
  "splitType": "equal"
}'

Add Expense - Petrol (₹300, paid by Om)

curl -X POST http://localhost:3000/api/expenses \
-H "Content-Type: application/json" \
-d '{
  "amount": 300,
  "description": "Petrol",
  "paidBy": "Om",
  "participants": ["Shantanu", "Sanket", "Om"],
  "splitType": "equal"
}'

Add Expense - Movie Tickets (₹500, paid by Shantanu)

curl -X POST http://localhost:3000/api/expenses \
-H "Content-Type: application/json" \
-d '{
  "amount": 500,
  "description": "Movie Tickets",
  "paidBy": "Shantanu",
  "participants": ["Shantanu", "Sanket", "Om"],
  "splitType": "equal"
}'

Add Expense - Pizza (₹280, paid by Sanket)

curl -X POST http://localhost:3000/api/expenses \
-H "Content-Type: application/json" \
-d '{
  "amount": 280,
  "description": "Pizza",
  "paidBy": "Sanket",
  "participants": ["Shantanu", "Sanket", "Om"],
  "splitType": "equal"
}'

List All Expenses

curl http://localhost:3000/api/expenses

Update Expense - Change Petrol to ₹350

Replace YOUR_EXPENSE_ID_HERE with the actual ID obtained from listing expenses.

curl -X PUT http://localhost:3000/api/expenses/YOUR_EXPENSE_ID_HERE \
-H "Content-Type: application/json" \
-d '{
  "amount": 350,
  "description": "Petrol",
  "paidBy": "Om",
  "participants": ["Shantanu", "Sanket", "Om"],
  "splitType": "equal"
}'

Delete Expense - Remove Pizza

Replace YOUR_EXPENSE_ID_HERE with the actual ID obtained from listing expenses.

curl -X DELETE http://localhost:3000/api/expenses/YOUR_EXPENSE_ID_HERE

Get All People

curl http://localhost:3000/api/people

Get Current Balances (after all transactions)

curl http://localhost:3000/api/balances

Get Settlement Summary (optimized transactions)

curl http://localhost:3000/api/settlements

Add Expense - Invalid (negative amount)

curl -X POST http://localhost:3000/api/expenses \
-H "Content-Type: application/json" \
-d '{
  "amount": -50,
  "description": "Invalid Negative Amount Test",
  "paidBy": "TestUser",
  "participants": ["TestUser"],
  "splitType": "equal"
}'

Add Expense - Invalid (empty description)

curl -X POST http://localhost:3000/api/expenses \
-H "Content-Type: application/json" \
-d '{
  "amount": 100,
  "description": "",
  "paidBy": "TestUser",
  "participants": ["TestUser"],
  "splitType": "equal"
}'

Add Expense - Invalid (missing paid_by)

curl -X POST http://localhost:3000/api/expenses \
-H "Content-Type: application/json" \
-d '{
  "amount": 100,
  "description": "Missing PaidBy Test",
  "participants": ["TestUser"],
  "splitType": "equal"
}'

Update Non-existent Expense

curl -X PUT http://localhost:3000/api/expenses/NON_EXISTENT_ID \
-H "Content-Type: application/json" \
-d '{
  "amount": 100,
  "description": "Attempt to update non-existent",
  "paidBy": "TestUser",
  "participants": ["TestUser"],
  "splitType": "equal"
}'

Delete Non-existent Expense

curl -X DELETE http://localhost:3000/api/expenses/NON_EXISTENT_ID

Get Balances - With No Expenses

curl http://localhost:3000/api/balances

Contributors

0xPratikPatil

Issues