LogicGoInfotechSpaces commited on
Commit
fa10656
·
1 Parent(s): c45fa23

Disable write endpoints; read-only analytics

Browse files
Files changed (1) hide show
  1. app/main.py +20 -10
app/main.py CHANGED
@@ -51,11 +51,16 @@ async def health_check():
51
 
52
  @app.post("/expenses", response_model=dict)
53
  async def create_expense(expense: Expense):
54
- """Create a new expense"""
55
- expense_dict = expense.model_dump()
56
- expense_dict["created_at"] = datetime.utcnow()
57
- result = db.expenses.insert_one(expense_dict)
58
- return {"id": str(result.inserted_id), "message": "Expense created successfully"}
 
 
 
 
 
59
 
60
  @app.get("/expenses", response_model=List[Expense])
61
  async def get_expenses(user_id: str, limit: int = 100):
@@ -68,11 +73,16 @@ async def get_expenses(user_id: str, limit: int = 100):
68
 
69
  @app.post("/budgets", response_model=dict)
70
  async def create_budget(budget: Budget):
71
- """Create a new budget"""
72
- budget_dict = budget.model_dump()
73
- budget_dict["created_at"] = datetime.utcnow()
74
- result = db.budgets.insert_one(budget_dict)
75
- return {"id": str(result.inserted_id), "message": "Budget created successfully"}
 
 
 
 
 
76
 
77
  @app.get("/budgets", response_model=List[Budget])
78
  async def get_budgets(user_id: str):
 
51
 
52
  @app.post("/expenses", response_model=dict)
53
  async def create_expense(expense: Expense):
54
+ """
55
+ Disabled: this service does not create expenses.
56
+
57
+ All expenses should be created by the main WalletSync app and stored
58
+ directly in MongoDB. This API only reads existing data for analytics.
59
+ """
60
+ raise HTTPException(
61
+ status_code=405,
62
+ detail="Creating expenses is disabled. Use the main WalletSync app to add expenses.",
63
+ )
64
 
65
  @app.get("/expenses", response_model=List[Expense])
66
  async def get_expenses(user_id: str, limit: int = 100):
 
73
 
74
  @app.post("/budgets", response_model=dict)
75
  async def create_budget(budget: Budget):
76
+ """
77
+ Disabled: this service does not create budgets.
78
+
79
+ All budgets should be created by the main WalletSync app and stored
80
+ directly in MongoDB. This API only reads existing data for analytics.
81
+ """
82
+ raise HTTPException(
83
+ status_code=405,
84
+ detail="Creating budgets is disabled. Use the main WalletSync app to add budgets.",
85
+ )
86
 
87
  @app.get("/budgets", response_model=List[Budget])
88
  async def get_budgets(user_id: str):